aspose file tools
The moose likes XML and Related Technologies and the fly likes how to remove indentation in a xml using java api Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "how to remove indentation in a xml using java api" Watch "how to remove indentation in a xml using java api" New topic
Author

how to remove indentation in a xml using java api

Akram Chotu
Ranch Hand

Joined: Apr 18, 2006
Posts: 43
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




to



using java. I want to resuse any xml parser api for achieving this. Can anyone please help me?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

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: http://aspose.com/file-tools
 
subject: how to remove indentation in a xml using java api
 
Similar Threads
Extracting specific section of large xml file.
what is SAX (event-based) parsing ?
Adding <pre> to an xml file
CDATA and PCDATA
Validating Parser