Open markusrempfer opened 4 years ago
I'm using node.js and xml2js to create a xml file. I'm not able to add to similar attributes to a tag thoug. So sth like this:
<?xml version="1.0" encoding="UTF-8"?> <data xmlns:xsi="url" xmlns="abc" xmlns="xyz" xsi:schema="123">
What I tried is:
js :
var obj = { 'data': { /*'$': { 'xmlns:xsi': 'url', 'xmlns': 'abc', 'xmlns': 'xyz', 'xsi:schema': '123' },*/ '$': { 'xmlns:xsi': 'url', 'xmlns': [ 'abc', 'xyz' ], 'xsi:schema': '123' } ... } }; var builder = new xml2js.Builder({ xmldec: {'version': '1.0', 'encoding': 'UTF-8'} }); var xml = builder.buildObject(obj); console.log(xml);
... which results in:
Attempt 1:
<?xml version="1.0" encoding="UTF-8"?> <data xmlns:xsi="url" xmlns="xyz" xsi:schema="123">
Attempt 2:
<?xml version="1.0" encoding="UTF-8"?> <data xmlns:xsi="url" xmlns="abc,xyz" xsi:schema="123">
But I need this:
Goal:
How can I render two similar attributes in the same element?
I'm using node.js and xml2js to create a xml file. I'm not able to add to similar attributes to a tag thoug. So sth like this:
What I tried is:
js :
... which results in:
Attempt 1:
Attempt 2:
But I need this:
Goal:
How can I render two similar attributes in the same element?