【发布时间】:2014-11-17 16:07:38
【问题描述】:
我正在尝试将 js 对象转换为 xml 字符串,我尝试使用以下插件
https://github.com/michaelkourlas/node-js2xmlparser
http://goessner.net/download/prj/jsonxml/
如果我给出如下数据
var data = {
"firstName": "John",
"lastName": "Smith"
};
它应该给出这样的结果
> <?xml version="1.0" encoding="UTF-8"?>
> <person firstName="John" lastName="Smith">>
> </person>
他们说在 js 属性中添加“underscode”或“@”前缀将使该属性成为属性,但我的 js 对象是动态创建的,所以我不能在每个属性属性之前添加“underscode”或“@” .
还有其他方法可以实现我想要的吗?
【问题讨论】:
标签: javascript xml json converter