Skip to content

Javascript and Python module to convert xml into a simple json format

License

Notifications You must be signed in to change notification settings

chucknthem/xml2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

var obj = XML2JSON.parse('
  <root>
    <withattr id="10" name="5">
      text
    </withattr>
    <nodes>1</nodes>
    <nodes x="y">2</nodes>
    <nodes><num n="3">3</num></nodes>
    <nodes>
      <num n="3">
        <i>hello</i>
      </num>
    </nodes>
    <nodes>
      <num>3</num>
      hi
    </nodes>                                                                      
  </root>
');
console.log(JSON.stringify(obj));
/*
{"root": 
  {
    "withattr": {"@attributes": {"id": "10", "name": "5"}, "@text": "text"},
    "nodes": [
      "1", 
      {"@attributes": {"x": "y"}, "@text": "2"}, 
      {"num": {"@attributes": {"n": "3"}, "@text": "3"}},
      {"num": {"@attributes": {"n": "3"}, {"i": "hello"}}}
      {"num": {"@attributes": {"n": "3"}, {"i": "hello"}}, "@text": "hi"}
      ]
  }
}
*/

About

Javascript and Python module to convert xml into a simple json format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published