I’m transforming a DOM document to XML in java using javax.xml APIs. The result is
<tag>
<tag2>text</tag2>
</tag>
but I need it to be
<tag>
<tag2>
text
</tag2>
</tag>
Are there any options to do that with text child nodes?
I didn’t find any
I think you will need to write your own marshaller to do this, as assuming you want this formatting to apply to all levels of XML you want to take the String
textand transform it intowhere n depends on the depth of the current element from the root element.
Explicitly, if you compare the values of xpath /tag/tag2 on both these documents they are not the same.