This project has moved. For the latest updates, please go here.

Trying to find an images with a class

Topics: User Forum
Jun 20, 2011 at 1:35 PM
Hi all,
Can someone help me extract an image on my page which has mainImage. This is the code I have - I know everything is working up and till I perform the foreachloop which give me a CS0021: Cannot apply indexing with [] to an expression of type 'HtmlAgilityPack.HtmlNode'
error, basically highlighting this line of code: HtmlAttribute srcPath = link["src"];

        HtmlDocument doc = new HtmlDocument();


        foreach(HtmlNode link in doc.DocumentNode.SelectNodes("//img[@class]='mainImage'"))
            HtmlAttribute srcPath = link["src"];


            HtmlAttribute att = link["href"];
            att.Value = FixLink(att);

Jun 20, 2011 at 9:14 PM

Hi Ive managed to get rid of that error. How do I put the results into ListView so I can use this in the front end of an aspx page.

Jun 21, 2011 at 3:35 PM

Managed to sort it out