【发布时间】:2014-08-24 05:29:17
【问题描述】:
我目前正在尝试使用 xml2js 通过流星解析 XML 并将其插入到 Mongodb 中。我使用以下代码在 server/fixtures.js 中执行此操作:
Iati.insert({
test: xml2js.parseString(Assets.getText('iati.xml'))
})
Xml2js 似乎确实转换了一些东西,但输出似乎很荒谬,即具有以下属性的对象:
test: Object
ENTITIES: Object
attribList: Array[0]
attribName: ""
attribValue: ""
bufferCheckPosition: 65536
c: ""
cdata: ""
closed: false
closedRoot: false
column: 0
comment: ""
doctype: ""
entity: ""
error: null
line: 0
looseCase: "toUpperCase"
noscript: true
opt: Object
position: 0
procInstBody: ""
procInstName: ""
q: ""
sawRoot: false
script: ""
sgmlDecl: ""
startTagPosition: 9347
state: 0
strict: true
tag: null
tagName: ""
tags: Array[0]
textNode: ""
trackPosition: true
__proto__: Object
__proto__: Object
我应该如何更改我的代码以获取实际的 XML 作为输出?提前致谢
【问题讨论】: