As far as I know, there is no direct way to do this. HtmlNode.CreateNode method creates a single node from an HTML fragment, if there are several nodes, the first one is created only.
As a workaround, you can create a temporary node, create its child nodes from sReplacementString , and then add these child nodes immediately after the inputNode node and finally delete the inputNode .
var temp = doc.CreateElement("temp"); temp.InnerHtml = sReplacementString; var current = inputNode; foreach (var child in temp.ChildNodes) { inputNode.ParentNode.InsertAfter(child, current); current = child; } inputNode.Remove();
source share