Any recommendation for xml to json for Node.js?

前端 未结 8 721
面向向阳花
面向向阳花 2020-12-08 15:14

I\'ve installed node-xml but I don\'t think it works the way I expect. and it doesnt\' have example. any recommendation for xml-2-json (js) for node.js? I also looked a

8条回答
  •  借酒劲吻你
    2020-12-08 15:31

    As the other poster points out, node-xmltojs is probably the best way to go.

    If you did want to use JSONML, I'm not sure why the JQuery plugin in the other answer is being upvoted: there's JSONML for node:

    npm install jsonml
    

    Example:

    var fs = require('fs'),
      parse = require('jsonml').parse;
    
    var jsonML = parse(fs.readFileSync('myfile.xml'));
    

提交回复
热议问题