I am looking for a JavaScript library that parses an XML string and converts it to a JavaScript object. What are some good ones?
Join them; it only takes a minute:
parses XML and returns a javascript object w/ a scheme that corresponds the xml. xml siblings w/ the same name are collapsed into arrays. nodes with names that can be found in the arrayTags parameter (array of tag name strings) always yeld arrays even in case of only one tag occurrence. arrayTags can be omitted. text nodes w/ only spaces are discarded. use console.log(parseXml(myxml)) to explore the output
|
|||||||||||||||||||||
|
Here's a nice xml2json and json2xml converter:
Here's another one: Depending on your needs, you might be able to use a standard parser (see http://www.w3schools.com/XML/tryit.asp?filename=tryxml_parsertest2) and xpath (http://www.w3schools.com/xpath/default.asp) - here's an example: and a few nice tutorials: |
|||||
|
The xml2json javascript file from https://bitbucket.org/surenrao/xml2json is all you need to do this. Here's the download link for quick download: https://bitbucket.org/surenrao/xml2json/get/0e0989dfe48e.zip Once included in your project, here's some sample code to get you started:
|
|||
|