我究竟做错了什么?我无法在子属性中获取标记的值.这是我的xml:
<root>
<time c="00:00:00">
<title>Title</title>
<text>Some Text...</text>
</time>
<time c="00:00:01">
<title>Title 2</title>
<text>Some text...</text>
</time>
</root>
Run Code Online (Sandbox Code Playgroud)
这就是我在节点中所做的:
xml2js = require('xml2js');
fs = require('fs');
var parser = new xml2js.Parser();
var timetag = '00:00:01';
fs.readFile( 'test.xml', function(err, data) {
parser.parseString(data, function (err, result) {
function sendSubs() {
io.sockets.emit('subs', { subs: result.root.time[c=timetag].title });
}
setInterval(sendSubs, 1000);
});
});
Run Code Online (Sandbox Code Playgroud)
我确定这是一个语法问题,但我没有看到它!,它可能得到两个孩子的价值,如标题和文字?
问候