another-json2xml is another JavaScript package for converting json to xml.
npm install another-json2xmlanother-json2xml is another JavaScript package for converting json to xml.
`` CMD`
npm install another-json2xml --save
` Typescript
import { XmlDef } from 'another-json2xml'
const xmlDef = new XmlDef()
xmlDef.method = "GetData"
// anotherSoap.defaultEnt = ""
// anotherSoap.tem = ""
// anotherSoap.methodNs = "m"
// anotherSoap.methodNsUrl = "http://tempurl.org/"
xmlDef.bodyEntities = [
{
name: "sessionId",
object: "XXXXX",
// ns: "ent2",
// nsUrl: "http://tempurl.org/"
},
{
name: "requestData",
// ns: "Foo",
// nsUrl: "http://schemas.datacontract.org/2004/07/Foo.Entities",
object: {
foo: "foo",
bar: "bar>",
empty: "",
tata: null,
bars: ["bar1", ""],
numbers: [1, 2],
booleans: [true, false],
cars: [
{
car: {
name: "car1",
brand: "Volkswagen"
},
},
{
car: {
name: car2<>&\"'<>&\"',
brand: "BMW"
},
},
],
},
},
]
const xml = xmlDef.toXML()
console.log(xml)
`
Output
` XML``
xmlns:tem="http://tempurl.org/"
xmlns:ent="http://schemas.datacontract.org/2004/07/ent.Entities"
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" >