I want to remove all empty nodes in a XML file. Even if the node is present as
<Node/> OR <Node></Node>
node should be deleted from the XML.
<Root type="1">
<A></A>
<B>
<B1>
<B12/>
<B13/>
</B1>
<B2>
123
<B21></B21>
</B2>
<B3 type="3">
<B4/>
</B3>
</B>
<C/>
</Root>
Expected output:
<Root type="1">
<B>
<B2>
123
</B2>
<B3 type="3">
</B3>
</B>
</Root>
Delete B1 node because all nodes under B1 is empty and also there is no attribute as well.
Do not delete B2 because , B2 has a value 123 , but delete its empty child.
Do not delete B3 because , B3 has an attribute, but delete its empty child.
I am using SQL to do the same , but in case if this can be done in c# as well , I can call C# script from SSIS, but SQL will be preferred.