Trying to get a single node with Html Agility Pack

TeapleTem

New Member
I m trying to get a single node after i locate the htmlnode with a specific tag. But what i get back is an error:\[quote\] Object reference not set to an instance of an object.\[/quote\]Now here is the code\[code\]HtmlWeb htmlWeb = new HtmlWeb();// Creates an HtmlDocument object from an URLHtmlAgilityPack.HtmlDocument document = htmlWeb.Load(url);// Targets a specific node// If there is no node with that Id, someNode will be nullHtmlNode someNode = document.GetElementbyId("<li name=\"XU\">");var parseString = someNode.SelectSingleNode("//span[@class='lp']");\[/code\]My purpose is to get all the nodes within the XU li tag. i know the name of the classes.Also just to note that when i m replacing the last code line with a \[code\]var parseString = document.DocumentNode.SelectSingleNode("//span[@class='long-position']");\[/code\]then the tag argument within the SelectSingleNode is working fine.
 
Back
Top