SelectSingleNode return null...

Topics: User Forum
Jan 20, 2012 at 3:52 PM
Edited Jan 20, 2012 at 3:53 PM

code is:

HtmlNode n = html.DocumentNode.SelectSingleNode("/html/body/div[@id=content]/table/tr/th/div/a");


when in debug, i manualy can found this node using ChildNodes from root.

but, why XPath cannot do it?(Windows XP, dotNET 4.0)

this page.

Jan 21, 2012 at 6:41 PM



You have missed the quotes around content!


If you use: "/html/body/div[@id='content']/table/tr/th/div/a"

Then it should work!

Just in case you haven't downloaded these two programs, you should. They make xpath a bit easier!

HAP Explorer

HAP Testbed

// Anders

Jan 21, 2012 at 7:33 PM

the reason was there i even dont try to look...

big thanks, but it means that not all expressions that System.Xml.XmlDocument support are supported.(it works without quotes )