I want to delete the empty nodes from an XML element.This xml is generated from a vendor and i dont have control on xml generation. But since the XML has few empty nodes i need to delete those empty nodes recursively.This xml is got from OMElement and i get an Element from this object using [XMLUtils][1] Sample XML\[code\]<A> <B> <C> <C1> <C11>something</C11> <C12>something</C12> </C1> </C> <D> <D1> <D11> <D111 operation="create"> <Node>something else</Node> </D11> </D11> </D1> <D2> <D21> </D21> </D2> </D> </B></A> \[/code\]Since D21 is an empty node i want to delete D21 and since now D2 is an empty node i want to delete D2 but since D has D1 i dont want to delete D.Similarly it is possible that i can get \[code\]<A> <B> <C> </C> </B></A>\[/code\]Now since C is empty i want to delete C and then B and then eventually node A.I am trying to do this using removeChild() method in NodeBut so far i am unable to remove them recursively. Any suggestions to remove them recursively?I am recursively trying to get node and node length. But node length is of no help\[code\]if(childNode.getChildNodes().getLength() == 0 ){ childNode.getParentNode().removeChild(childNode); }\[/code\]Regards
Dheeraj Joshi
Dheeraj Joshi