Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to remove indents from xml?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<view>
<help>
<block>No.1</block>
<device>USB</device>
</help>
</view>

How could I output the xml to :
<?xml version="1.0" encoding="UTF-8"?><view><help><block>No.1</block><device>USB</device></help></view>

The reason to output like this is to make the xml comparison passed.
I use org.custommonkey.xmlunit.XMLTestCase.compareXML to compare two xml string, one from Java code, the other from C# code. Now, since there are new line and whitespaces embedded in the Java generated XML, the comparison always failed. Is there any way to output the indent xml to the one string only?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!