Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to remove indentation in a xml using java api  RSS feed

 
Akram Chotu
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!