XML to JavaScript Object

后端 未结 4 1780
情歌与酒
情歌与酒 2020-11-27 19:12

I am looking for a JavaScript library that parses an XML string and converts it to a JavaScript object. What are some good ones?

4条回答
  •  醉话见心
    2020-11-27 19:39

    Here's a nice xml2json and json2xml converter:

    • http://goessner.net/download/prj/jsonxml/
      • Related tutorial: http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html

    Here's another one:

    • http://www.kawa.net/works/js/xml/objtree-e.html

    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:

    • http://snippets.dzone.com/posts/show/5272

    and a few nice tutorials:

    • http://www.nczonline.net/blog/2009/03/17/xpath-in-javascript-part-1/
    • https://developer.mozilla.org/en/introduction_to_using_xpath_in_javascript

提交回复
热议问题