i have a string in single line
String s = "<Item><productname>COOLER MASTER Hyper 212 EVO RR-212E-20PK-R2
</productname><Price>$33.99</Price><ItemID>1000</ItemID></Item>";
inside the above string , after the “>” new line should started and required output should like
<Item>
<productname>COOLER MASTER Hyper 212 EVO RR-212E-20PK-R2 </productname>
<Price>$33.99</Price>
<ItemID>1000</ItemID>
</Item>
Another option is to parse the XML, and use the OutputKeys.INDENT option of the Transformer class to output the XML formatted.
The following example
produces the output below