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 (only the last one is rendered):
<?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:
<?xml version="1.0" encoding="UTF-8"?>
<data xmlns:xsi="url" xmlns="abc" xmlns="xyz" xsi:schema="123">
How can I render two similar attributes in the same element?