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

Manipulating isolated HTML nodes outside of document

Topics: Developer Forum, User Forum
Aug 10, 2012 at 5:00 PM

Hi folks

Can anybody give me an idea if Html Agility Pack would be the right way to go for an issue I need to solve? I have isolated fragments of HTML code, stripped out of a page as <p> nodes each as a string. I need to be able to modify each <p> node, e.g., remove all the attributes from each <p> node. Can I have HAP individual strings, and ask it to remove all the attributes from within the opening <p .... > node markup? In other words, I would need to change this:

<p class="foo" tabindex="bar" ...>My first node content</p>

<p class="foo" tabindex="bar" ...>My second node content</p>

into this:

<p>My first node content</p>

<p>My second node content</p>

But I have already extracted the nodes above as strings, so in other words I would not be providing HAP with a reference to a full HTML document, just HTML fragments.

If anybody knew whether HAP would be a good way forward to do this, I would be very grateful to find out ...