Correct XPath yields empty result

BexBatavola

New Member
I'm trying to select a node from a html page based on the id of the node. Due to external restrictions I have to do that using XPath.I want to get the container element of the postings of a forum, in this case of Delphi-PRAXiS. I have attached a simple example of the page.The node I need is a div with the id "posts", so my query would be \[code\]//div[@id='posts']\[/code\].The problem is, the result is an empty list. If I query using \[code\]//*[@id='posts']\[/code\] I get my node.I tried this using the XmlDocument class of the framework.Eventually I want to use the Html Agility Pack (wich uses the same XPath class as the XmlDocument) but if I use that I get no results regardless of the query string.I know the query string is correct, so my guess would be that the parser is faulty. But somehow I doubt Microsoft would ship a broken XPath parser.Any suggestions?\[code\]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de"> <head> <title>Some title</title> </head> <body> <div> <div class="page"> <div id="dp-page" class="round-all"> <div class="dpbox"> <div id="posts"> Here we go! </div> </div> </div> </div> </div> </body></html>\[/code\]I found another clue: If the node \[code\]<a name="poststop" id="poststop"></a>\[/code\] is present in the xml the query fails, otherwise it succeeds. But why?
 
Back
Top