I'm serializing an XML document to String using JavaScript, but I can't get rid of the line breaks.
Simple XML Example:
<list>
<item label='one'/>
<item label='two'/>
</list>
When I use:
var xmlSerializer = new XMLSerializer();
xmlString = xmlSerializer.serializeToString(xml);
...the line breaks and indentations are preserved (visible when printing xmlString) but I want the whole XML to look like this:
<list><item label='one'/><item label='two'/></list>
I tried this:
xmlString.replace(/(\r\n|\n|\r)/gm,"");
...but I don't find it a reliable and clean solution. It should only affect the XML structure, not the content within the XML elements.
Any idea?