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

New Post: how to get attribute value plz

$
0
0

Here's how I would do it:

HtmlWeb.LoadAsync(url, handleResults);

public void handleResults(object o, HtmlDocumentLoadCompleted args)
{
     IEnumerable<HtmlNode> columns = args.Document.DocumentNode.Descendants("td").Where(x => x.GetAttributeValue("class", "").Equals("val"));

}

If you're looking to get the title inside of each image inside of the column, and assuming each column has exactly one image in it, you could add to this,

IEnumerable<string> titles = columns.Select(x => x.Descendants("img").Single().GetAttributeValue("title", ""));

Viewing all articles
Browse latest Browse all 655


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