This project has moved and is read-only. For the latest updates, please go here.

how to get attribute value plz

Topics: User Forum
May 7, 2012 at 12:16 PM
Edited May 7, 2012 at 12:20 PM


i need to get all the title attributes value ,only those who in the <td class = val>

<td class="val"><img class="r3" src="img/x.gif" alt="ind" title="ind" />
750 </td>
May 11, 2012 at 5:03 PM
Edited May 11, 2012 at 5:05 PM

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", ""));