I have a String which is XML data. After removing some nodes and adding few. The xml data is having lot of white spaces in it (created during the node removal.)
<A>
<B>
</B>
<!-- some node i deleted and lot of white spaces -->
<c>
</c>
<!-- some more node i deleted and lot of white spaces -->
<E>
</E>
Desired output after String manipulation
<A>
<B>
</B>
<c>
</c>
<E>
</E>
</A>
I can use replaceAll("\s","") but this removes even the new line character and make the xml out of structure for displaying it in UI.
Is there a way to trim it without trimming the new line character?
Edit: This XML data is part of OMElement