A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
XML and Related Technologies
how to remove indentation in a xml using java api
Joined: Apr 18, 2006
Jul 29, 2006 17:00:00
Basically I have formatted and indented xml and I want to convert that to a unformatted and non-indented , single line xml. For example how can I convert this
<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>
. I want to resuse any xml parser api for achieving this. Can anyone please help me?
Joined: Oct 14, 2005
Jul 29, 2006 21:17:00
You could read it into a DOM, then delete any nodes that are text nodes that contain only whitespace. Or you could write an XSLT template that copies all nodes except text nodes that contain only whitespace.
I agree. Here's the link:
subject: how to remove indentation in a xml using java api
CDATA and PCDATA
Extracting specific section of large xml file.
Adding <pre> to an xml file
what is SAX (event-based) parsing ?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014