I have some input tags that are placeholders that I am replacing with some HTML. A lot of the time the HTML I’m replacing them with is only one tag, which is easy enough:
HtmlNode node = HtmlNode.CreateNode(sReplacementString);
inputNode.ParentNode.ReplaceChild(node, inputNode);
However if I want to replace inputNode with two or more nodes HtmlNode.CreateNode(sReplacementString) only reads the first node. Is there a way to do a replace where sReplacementString is multiple tags?
As far as I know, there is no direct way to do it.
HtmlNode.CreateNodemethod creates a single node from the HTML snippet, if there are several nodes there, the first one is created only.As a workaround you could create a temporary node, create its child nodes from the
sReplacementString, and then append these child nodes right after theinputNodenode, and, finally, remove theinputNode.