SelectSingleNode return null...

Topics: User Forum
Jan 20, 2012 at 4:52 PM
Edited Jan 20, 2012 at 4: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 http://www.pwdatabase.com/ru/lvl/0-9 page.

Jan 21, 2012 at 7:41 PM

Hello,

 

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  http://htmlagilitypack.codeplex.com/releases/view/44954

HAP Testbed http://haptestbed.codeplex.com/

// Anders

Jan 21, 2012 at 8: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 )