Trying to find an images with a class

Topics: User Forum
Jun 20, 2011 at 2: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"];
Thanks
paps

        HtmlDocument doc = new HtmlDocument();

        doc.LoadHtml(contentItem.Html);

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

            //Response.Write(srcPath.Value);

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

        }
Jun 20, 2011 at 10: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 4:35 PM

Managed to sort it out