x2js
x2js copied to clipboard
Text element order gets changed when doing "xml to json" and "json to xml"
x2js is great! But, facing the below issues... can you provide solution for it?
<tree>
<node1>
textTextText
<subnode1> text1 </subnode1>
<subnode2> text2 </subnode2>
</node1>
</tree>
when doing xml to json
{
"tree": {
"node1": {
"subnode1": "text1",
"subnode2": "text2",
"__text": "textTextText"
}
}
}
- And 'json to xml'
<tree>
<node1>
<subnode1>text1</subnode1>
<subnode2>text2</subnode2>
textTextText
</node1>
</tree>
As you can see, the text nodes are pushed to last when reconverting.
Any luck with this thread?
<tree>
<node1>
textTextText
<subnode1> text1 </subnode1>
<subnode2> text2 </subnode2>
</node1>
</tree>
may be converted to
{
"tree": {
"node1": {
"#text": " \n textTextText \n ",
"subnode1": " text1 ",
"subnode2": " text2 "
}
},
"#omit-xml-declaration": "yes"
}