Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text element order gets changed when doing "xml to json" and "json to xml" #65

Open
sk8terboi87 opened this issue Nov 30, 2017 · 2 comments

Comments

@sk8terboi87
Copy link

sk8terboi87 commented Nov 30, 2017

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"
    }
  }
}
  1. 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.

@dougn7
Copy link

dougn7 commented Jul 9, 2018

Any luck with this thread?

@javadev
Copy link

javadev commented Jun 28, 2019

<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"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants