Is it possible to use the HAP (HTML Agility Pack) to:
- Grab a collection of nodes e.g. all
<a>
elements which are children of<li>
elements - Iterate over the collection
- Add CSS class references into the class attribute for each element e.g.
class &= "foo"
- Update the nodes in their original position within the HTML
For point 4, I need to know whether:
- When I grab a collection of nodes, am I working with copies?
- If so, can I easily update the nodes in their original position within the HTML
Finally, would it be practical to do this when rendering a page in an ASP.NET website, considering:
- I will need to modify the class references for no more than 100 elements
- I am not working with large HTML documents
- I plan to select my nodes starting at a div e.g.
div[2]
where body contains 4divs
I realise that this may seem like a bunch of separate questions but really it is just a breakdown of the following two questions:
- Can I easily modify the HTML output of an ASP.NET page e.g. to insert class references?
- Would it be practical to do this on 50 - 100 elements WRT speed e.g. no more than 2 seconds cost?
Many thanks.