HTMLAgilityPack - Remove Node with out stripping the inner text

后端 未结 1 1187
不知归路
不知归路 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
    <h5 align="left">Table 
    of Contents<br></h5>
    
    0 讨论(0)
提交回复
热议问题