converts json to xml
npm install convertjson2xmlconvertJSON2XML


=========
A small library that converts json to xml.
npm install convertjson2xml
``
const jsonToXML = require('convertjson2xml');
let xml = jsonToXML({
a: 1,
b: [2,3],
c: [],
d: {},
e: '',
});
console.log(xml);
`
Output should be
``
1
2
3
To put attributes on a tag, use the '@' field:
`
let xml = jsonToXML({
a: {
'@': {
'attribute': 'true',
},
value: 1,
},
b: [2,3],
c: {
'@': {
anotherAttribute: 'true',
},
'_': 'insideC',
},
});
console.log(xml);
`
Output should be
``
2
3
You can also change the root field by inserting it as the second argument:
`
let xml = jsonToXML({
a: {
'@': {
'attribute': 'true',
},
value: 1,
},
b: [2,3],
c: {
'@': {
anotherAttribute: 'true',
},
'_': 'insideC',
},
},'thisisthenewroot');
console.log(xml);
`
Output should be
``
2
3
npm test`