The HTML Agility Pack generates a new HTMLNode.

html html-agility-pack indexing parsing

Question

I'm parsing and transforming an HTML file using HTML Agility Pack, but when I attempt to create a new HTMLNode due to the index argument, I receive an issue saying "Item has already been inserted."

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 a node is created (intentionally imitating System.Xml semantics):

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

I'm not familiar with the constructor you use; maybe a new one will be made 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