Want to select one occurance not all

Jun 29, 2011 at 2:22 PM
Edited Jun 29, 2011 at 2:24 PM

Can Somone tell me how to get the following code working?

if (HtmlNode link in doc.DocumentNode.SelectSingleNode("//img]") != null) PathToImgs = link.Attributes["src"].Value;

I have this working chunk of code working but it selects all of the occurances of img's rather than a single (first) one I want.

Thanks

foreach(HtmlNode link in doc.DocumentNode.SelectNodes("//img")) {

 

PathToImgs = link.Attributes["src"].Value;

 }