I have the following HTML:
<div id="main-body">
<div id="answerform">
// ... a few children here i want
<form id=mwanser">
</form>
</div>
</div>
I want everything in the main-body, except what is in the form tag… (and don’t want the form tag itself too)….
I tried with XPath a lot but i didn’t succeed.
I’m working with C# and HTMLAgilityPack, maybe there’s a way to navigate to the child and delete it instead? The first option for me must be XPath too.
With XPath if you select a node you obtain the node and every descendant in it. What you can do is select the children directly but the unwanted node. Taking your sample as a test, you can write: