问题:我需要删除所有
我也尝试过使用
标签的style属性,如果它包含font-weight:bold属性,则添加标签。
SOME TEXT HERE
输出应该是:SOME TEXT HERE
我正在使用以下代码:var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(htmlPage);
foreach (var htmlTag in attributetags)
{
var Nodes = htmlDocument.DocumentNode.SelectNodes("//p");
if (Nodes != null)
{
bool flag = false;
foreach (var Node in Nodes)
{
if (Node.Attributes["style"] != null)
{
if (Node.Attributes["style"].Value.Contains("font-weight:bold"))
{
var bnode = HtmlNode.CreateNode("<b>");
Node.PrependChild(bnode);
}
Node.Attributes.Remove("style");
}
}
}
}
我也尝试过使用
Node.InsertAfter(bcnode, Node), Node.InsertBefor(bnode, Node)
。