wankdanker / node-object-to-xml

Convert any JavaScript object to XML
MIT License
19 stars 8 forks source link

Minified output #12

Closed real050280 closed 7 years ago

real050280 commented 7 years ago

How do you guys minify the generated output into one-line removing indentations?

wankdanker commented 7 years ago

Unfortunately, there is no option to turn that off although it would be really nice if there was. So, you'll probably have to do some sort of regex replace.

Something like this should work:

var o2x = require('object-to-xml');
var obj = { a : { b : 1234 } };

var xml = o2x(obj).replace(/>\s*/g, '>').replace(/\s*</g, '<');

console.log(xml);
//<a><b>1234</b></a>