I'm running the following code using xml2js to create my XML from a JSON struct. I have the following code:
const xml2js = require('xml2js')
const JSONObject = {
order: {
client: 'thomas',
itens: {
item: {
id: 1
},
item: {
id: 2
}
}
}
}
const builder = new xml2js.Builder();
const xml = builder.buildObject(JSONObject);
console.log(xml)
With the following output:
<order>
<client>thomas</client>
<itens>
<item>
<id>2</id>
</item>
</itens>
</order>
What can i do so the output is something like this?
<order>
<client>thomas</client>
<itens>
<item>
<id>1</id>
</item>
<item>
<id>2</id>
</item>
</itens>
</order>
Thanks so much in advance! :)