i need to remove the tag if the class value is "Section2 RenderAsSection2"
This is the input
<body>
<div id="Sec3" class="Section2 RenderAsSection2">
<h3 class="Heading"><span class="HeadingNumber">1.1.2 </span>Text1</h3>
<div class="Para ParaOneEmphasisChild">Text 2 <span class="EmphasisTypeItalic">decay</span>. Text3</div><div class="Para">Text4 <span class="EmphasisTypeItalic">decay</span> processes.</div>
</div>
</body>
and this should be the output
<body>
<h3 class="Heading"><span class="HeadingNumber">1.1.2 </span>Text1</h3>
<div class="Para ParaOneEmphasisChild">Text 2 <span class="EmphasisTypeItalic">decay</span>. Text3</div><div class="Para">Text4 <span class="EmphasisTypeItalic">decay</span> processes.</div>
</body>
this is my code
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(@"1.html");
var en = doc.DocumentNode.Descendants("div");
var ll = en.ToList();
foreach (var item in ll)
{
foreach (var att in item.Attributes)
{
if (att.Value == "Section2 RenderAsSection2")
{
item.ParentNode.RemoveChild(item, true);
}
}
}
But the output is
<body>
<div class="Para">Text4 <span class="EmphasisTypeItalic">decay</span> processes.</div><div class="Para ParaOneEmphasisChild">Text 2 <span class="EmphasisTypeItalic">decay</span>. Text3</div>
<h3 class="Heading"><span class="HeadingNumber">1.1.2 </span>Text1</h3>
</body>
How does it became that way?
Thank you.