HTMLAgilityPack - Remove Node with out stripping the inner text

后端 未结 1 1213
不知归路
不知归路 2021-01-19 06:15

My html content is

asdf
1条回答
  •  青春惊慌失措
    2021-01-19 06:53

    Remove the node from parent while keeping the grand children

    foreach (var Node in Nodes)
    {
        Node.ParentNode.RemoveChild(Node, true); //<-- keepGrandChildren
    }
    
    var newhtml = htmlDocument.DocumentNode.OuterHtml;
    

    output:

    asdf
    
    Table of Contents

    0 讨论(0)
提交回复
热议问题