为什么我收到“无效的 XML”信息?在 Node.js 中调用 jQuery.parseXML 时?
当我这样做时:
require('jquery').parseXML('<foo>bar</foo>');
我得到:
Invalid XML: <foo>bar</foo>
在浏览器中调用等效项 ($.parseXML('
) 似乎工作正常。我做错了什么?
我正在使用通过 NPM 安装的 Node.js v0.6.6 和 jquery v1.6.3。
如果有更合适的方法在 Node.js 中将字符串解析为 XML 文档,我也有兴趣学习。
When I do this:
require('jquery').parseXML('<foo>bar</foo>');
I get this:
Invalid XML: <foo>bar</foo>
Calling the equivalent in the browser ($.parseXML('<foo>bar</foo>')
) seems to work fine. What am I doing wrong?
I am using Node.js v0.6.6 and jquery v1.6.3 installed via NPM.
If there is a more appropriate way to parse a string into an XML document in Node.js, I would be interested in learning that as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想将其转换为 javascript 对象,你可以尝试 node-xml2js 。
You can try node-xml2js if you want to have it converted to javascript object.