开发者

Removing tags w/ prefix using HTML Agility Pack

I'm trying to access tags with prefix using HAP but the following do not work (they return nothing):

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

Any thoughts?

EDIT:

HTML looks like this: <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开发者_如何学Go/9860_" id="WC_9860"></sc:xslfile></p>

@Pat, I tried starts-with but still no go.

Maybe because the tags are empty?


You may be able to use the starts-with selector.

i.e:

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

Where @class is the attribute you are looking for.

Update:

If you're interested in just the datasource and/or id you could run:

//*[@datasource]

or

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

However knowing what you're trying to extract would help refine the selector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜