Html Agility Pack - Remove element, but not innerHtml

后端 未结 10 2135
予麋鹿
予麋鹿 2021-01-06 11:46

I can easily remove the element just by note.Remove() lik this:

HtmlDocument html = new HtmlDocument();

html.Load(Server.MapPath(@\"~\\Site\\themes\\default         


        
10条回答
  •  梦谈多话
    2021-01-06 12:13

    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
    doc.LoadHtml(html);
    
    var node = doc.DocumentNode.SelectSingleNode("//removeme");
    node.ParentNode.RemoveChild(node, true);
    

提交回复
热议问题