【发布时间】:2014-05-15 21:09:15
【问题描述】:
我正在尝试解析如下所示的 XML 文件:
<body>
<predictions>
<direction>
<prediction epochTime="1400182631361" seconds="1109" minutes="18" isDeparture="false" dirTag="N__OB1" vehicle="1495" vehiclesInConsist="2" block="9708" tripTag="6041030"/>
<prediction epochTime="1400182942181" seconds="1420" minutes="23" isDeparture="false" dirTag="N__OB1" vehicle="1515" vehiclesInConsist="2" block="9709" tripTag="6041031"/>
<prediction epochTime="1400183687220" seconds="2165" minutes="36" isDeparture="false" dirTag="N__OB1" vehicle="1481" vehiclesInConsist="2" block="9710" tripTag="6041032"/>
<prediction epochTime="1400183966372" seconds="2444" minutes="40" isDeparture="false" affectedByLayover="true" dirTag="N__OB1" vehicle="1520" vehiclesInConsist="2" block="9712" tripTag="6041033"/>
<prediction epochTime="1400184566372" seconds="3044" minutes="50" isDeparture="false" affectedByLayover="true" dirTag="N__OB1" vehicle="1430" vehiclesInConsist="2" block="9713" tripTag="6041034"/>
</direction>
</predictions>
</body>
我想使用 Xpath(通过“/body/predictions/direction/@seconds”)提取每个 prediction 节点内的所有 seconds 属性,但它没有为我返回任何内容。有什么想法吗?
【问题讨论】:
标签: javascript xml xpath