0
我想使用下面的方法刪除空節點。但我得到的錯誤HTMLAgilityPack.HtmlNode不包含刪除的定義
containerNode.Remove();
說「HTMLAgilityPack.HtmlNode不包含刪除....」的定義。我應該參考使用HTMLAgilityPack的Remove方法,而不是「使用HtmlAgilityPack」。
static void RemoveEmptyNodes(HtmlNode containerNode)
{
if (containerNode.Attributes.Count == 0 && (containerNode.InnerText == null || containerNode.InnerText == string.Empty))
{
containerNode.Remove();
}
else
{
for (int i = containerNode.ChildNodes.Count - 1; i >= 0; i--)
{
RemoveEmptyNodes(containerNode.ChildNodes[i]);
}
}
}
在我的方法,我用下面這是離開了像emtpy節點之一,,等
myNode.RemoveAll();
myNode.RemoveAllChildren()
我怎樣才能取出空節點?
這是一個版本問題。下載最新的dll(1.4.6),它解決了這個問題。我現在有刪除方法 – San 2013-02-19 07:06:55
回答你的問題,並接受它,如果問題自己解決 - 不要留下一個問題沒有回答。 – Alex 2013-02-19 13:55:55