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

Replace images with alternate text

Topics: User Forum
Jun 20, 2011 at 10:03 PM

I need to parse HTML for images and replace those tags with a new tag that just has the text that is contained in the alternate. Can someone show how to do this with both linq and standard usage?

I've using a linq sample now to replace paragraphs. But, I'm getting a read only error.

        HtmlDocument doc = new HtmlDocument();
        IEnumerable<HtmlNode> paragraphs = doc.DocumentNode.DescendantNodes().Where(p => p.Name.ToLower() == "p");
        foreach (HtmlNode p in paragraphs)
            p.InnerText = "Hello World";