This content has been marked as final. Show 3 replies
AllenZhao wrote:"well formatted"? You're confusing this with "well formed".
Does anyone know how to make a xml stream to be well formatted?
For example, if I got a String like:Yeah, get something that will "pretty print" the XML for you. I believe JDOM can do it out of the box.
String a = "<person><name>Jack</name><age>16</age></person>";
And I need to convert it to be well formatted like
are you trying to format it while you are steaming it? that would be a bit difficult to get it how you want it, but this is possible:
if you can read the entire string in before formatting, then its not that hard after you come up with an algorithm
<person> <name> Jack </name> <age> 16 </age> </person>
why are you doing this?
The reason I'm doing that is to show the user clearly difference between two similar xml streams. I think I got it. Just use XMLOutputter's output method. Thanks everyone!