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")
{
oldElement.Remove();
}
All tables are indeed removed, so I'm sure that i'm accessing the correct nodes.
See Question&Answers more detail:os