An ultimate tool to parse XMl int JSON format, with awesome result.
npm install easy-xml-parserJavaScript
xmlToJson(
);
// will generate
{
"root": {
"param": [
{
"arg1": "some value"
},
{
"arg1": "some value"
},
{
"arg1": "some value"
}
],
"param2": "Text sample",
"param3": "Text sample",
"param4": {
"arg": 12,
"prop": 123,
"inner": {
"arg": 123
},
"inner2": [
{
"arg": 123
},
{
"arg": 123
},
{
"arg": 123
}
]
}
}
}
jsonToXml({
root: {
param: [
{
arg1: "some value",
},
{
arg1: "some value",
},
{
arg1: "some value",
},
],
param2: "Text sample",
param3: "Text sample",
param4: {
arg: 12,
prop: 123,
inner: {
arg: 123,
},
inner2: [
{
arg: 123,
},
{
arg: 123,
},
{
arg: 123,
},
],
},
},
});
// will generate
`
Important Bahavior
`JavaScript
// Text content of XML tag will replace all attributes with
xmlToJson(
)
// will generate
{
root: {
param: "Text content"
}
}
// next example
xmlToJson(
)
// will generate
{
"root": {
"param": [
"Text content",
"Text content",
"Text content"
]
}
}
// Single XMP tag will become as attribute and will replace exisiting one with the same name
``