[ 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')]

Leave a comment