One of the possible way to address this problem:
You string looks like a well-formed XML which is not too big. You can pass it as XML. You can do it using the class
System.Xml.XmlTextReader
to get a DOM structure or the class
System.Xml.Linq.XDocument
to get a document tree structure. In both cases, you will get a structured document with access to your HTML nodes. Modify the nodes as you need and serialize the document back to XML text.
See:
http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[
^],
http://msdn.microsoft.com/en-us/library/bb387063.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx[
^].
[EDIT: in case of not well-formed XML]
If HTML can be not a well-formed XML, you can use appropriate HTML parser. Try this:
http://www.majestic12.co.uk/projects/html_parser.php[
^].
—SA