HTML agility package creates new HTMLNode

I use the HTML Agility Pack to parse and convert the HTML file, but I get an “Item Already Added” exception when trying to create a new HTMLNode due to 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"; 
+8
html parsing indexing html-agility-pack
source share
1 answer

Here's how you can create a node (it basically mimics the semantics of System.Xml, specifically):

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

I don’t know about this used constructor, perhaps new, available in version 1.4?

+18
source share

All Articles