2

HAPを使用してプレフィックス付きのタグにアクセスしようとしていますが、以下は機能しません(何も返されません)。

HtmlAgilityPack.HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//*[name() ='sc:xslfile']");
HtmlAgilityPack.HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//*['sc:xslfile']");

何かご意見は?

編集:

HTMLは次のようになります。 <p>Men's Standings<br /> <sc:xslfile runat="server" datasource="/Global/Tables/1_01/9859_" id="WC_9859"></sc:xslfile> <br /><br /><br /> Women's Standings <br /><sc:xslfile runat="server" datasource="/Global/Tables/1_01/9860_" id="WC_9860"></sc:xslfile></p>

@Pat、私はstartsを試しましたが、それでもうまくいきません。

タグが空だからか?

4

1 に答える 1

2

start-withセレクターを使用できる場合があります。

すなわち:

var nodes = document.DocumentNode.SelectNodes("//*[starts-with(@class, 'cnn_')]");

ここで、@classは探している属性です。

アップデート:

データソースやIDのみに関心がある場合は、次のコマンドを実行できます。

//*[@datasource]

また

//*[contains(@id, 'WC_']

ただし、何を抽出しようとしているのかを知っていると、セレクターを改良するのに役立ちます。

于 2010-01-20T22:36:19.313 に答える