node-js2xmlparser icon indicating copy to clipboard operation
node-js2xmlparser copied to clipboard

when use '#', the text will have \n

Open lixueying opened this issue 8 years ago • 1 comments

const js2xmlparser = require("js2xmlparser") const obj = { somefield: { '#': some thing, 'otherfield': 'other thing' } }; js2xmlparser.parse("test", obj);

Produces the following xml: <?xml version='1.0'?> <test> <somefield> some thing <otherfield> other thing</otherfield> </somefield> </test>

But I want the xml (when I watch the view-source): <?xml version='1.0'?> <test> <somefield>some thing<otherfield> other thing</otherfield></somefield> </test>

Anyone knows how to implement this?

lixueying avatar Sep 05 '18 08:09 lixueying

find one way can fix it. add one param { format: { pretty: false } } e.g. js2xmlparser.parse('test', obj, { format: { pretty: false } });

lixueying avatar Sep 07 '18 03:09 lixueying