Surround existing node with another node with Agility Pack
问题 How would you go about surrounding all tables with a <div class="overflow"></div> node? This apparently does not do it: if (oldElement.Name == "table") { HtmlDocument doc = new HtmlDocument(); HtmlNode newElement = doc.CreateElement("div"); newElement.SetAttributeValue("class", "overflow"); newElement.AppendChild(oldElement); oldElement.ParentNode.ReplaceChild(newElement, oldElement); } Nothing happens to the tables when I try that code. But if i use: if (oldElement.Name == "table") {