Any recommendation for xml to json for Node.js?

前端 未结 8 736
面向向阳花
面向向阳花 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:37

    There are many xml parsers.

    Like libxmljs and node-o3-xml. The latter is made and used by Ajax.org so it should be stable.

    As for converting XML to JSON, I would recommend creating an object structure from your xml and then manually calling JSON.stringify on it. This gives you complete control of how your xml data is turned into JSON.

    You can then either save the JSON in a file/DB or serve it to a request.

提交回复
热议问题