对Node.js的xml到json有任何建议吗? [英] Any recommendation for xml to json for Node.js?

查看:93
本文介绍了对Node.js的xml到json有任何建议吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了node-xml,但是我认为它没有按我期望的方式工作.它没有例子.对node.js的xml-2-json(js)有什么建议吗?我还在npm中查看了xml2js,但是它已被弃用,人们报告说它已被最新的node.js破坏了

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 at xml2js in npm but it is deprecated and people reported that it is broken with the latest node.js

顺便说一句,我也在用快递. :)

by the way, i'm also using express. :)

推荐答案

有许多类似于 libxmljs 节点-o3-xml .后者是由Ajax.org制作和使用的,因此应该稳定.

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

对于将XML转换为JSON,我建议从您的xml创建一个对象结构,然后在其上手动调用JSON.stringify.这使您可以完全控制如何将xml数据转换为JSON.

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.

然后您可以将JSON保存在文件/数据库中,也可以将其提供给请求.

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

这篇关于对Node.js的xml到json有任何建议吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆