[ StackOverflow ] – Know if an attribute contains a value in HTMLAgilityPack’s C# Node Collection

xml – What is the correct XPath for choosing attributes that contain “foo”? – Stack Overflow

The link above is quite interesting for HTMLAgilityPack C# beginners, helps a lot !

Another thing to note is that while the XPath above will return the correct answer for that particular xml, if you want to guarantee you only get the “a” elements in element “blah”, you should as others have mentioned also use

/bla/a[contains(@prop,'Foo')]

This will search you all “a” elements in your entire xml document, regardless of being nested in a “blah” element

//a[contains(@prop,'Foo')]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s