The HTML Agility Pack generates a new HTMLNode.

html html-agility-pack indexing parsing

Question

I'm using HTML Agility Pack to parse and transform a HTML file, but I get an exception "Item has already been added" when try to create a new HTMLNode because of the index parameter.

HtmlNode node1 = new HtmlNode(HtmlNodeType.Element, doc, 0); 
node1.Name = "div"; 

HtmlNode node2 = new HtmlNode(HtmlNodeType.Element, doc, 0); 
node2.Name = "div"; 
1
9
3/23/2011 1:25:54 AM

Accepted Answer

This is how you can create a node (it basically mimics System.Xml semantics, on purpose):

    HtmlNode div = doc.CreateElement("div");
    myNode.Append(div);

I don't know about this constructor you use, maybe a new one available in version 1.4?

21
3/21/2011 7:57:37 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow