Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Children nodes

$
0
0

Hi Labu

here is a solution

AP.HtmlDocument hp = new AP.HtmlDocument();
hp.LoadHtml("<tr data-stopcode=\"F01093\">    <td>5</td>    <td ><span>Fifth street</span></td></tr>");

var nodes = hp.DocumentNode.SelectNodes("//tr[@data-stopcode]//span");
foreach (AP.HtmlNode node in nodes)
{
    string stopname = node.InnerText;
}

So I'm looking for all tr nodes with the attribute stopcode and looking for the span after and getting the text from the span.
hope this helps and you can see why it works

as for your sample the second one you are looking for the last child of the document which is now tr then the first child which is the spaces you have before the first td and your getting the text which is " "

hp.DocumentNode.LastChild.FirstChild.InnerText = " ";

Lee.


Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>