在使用xpath时(我使用的时间不是很长),我发现了一些奇怪的东西。
XML的简化版本(完整的xml在这里,快照可在pastebin上找到):
<?xml version="1.0" encoding="utf-8" ?>
<body copyright="All data copyright San Francisco Muni 2013.">
<route tag="all">
<message id="10268" creator="jflynn" startBoundary="1378121400000" startBoundaryStr="Mon, Sep 02 04:30:00 PDT 2013" endBoundary="1378191540000" endBoundaryStr="Mon, Sep 02 23:59:00 PDT 2013" sendToBuses="false">
<text>Sunday schedules today.</text>
</message>
</route>
<route tag="44">
<message id="10221" creator="mlee" startBoundary="1377525600000" startBoundaryStr="Mon, Aug 26 07:00:00 PDT 2013" endBoundary="1382857140000" endBoundaryStr="Sat, Oct 26 23:59:00 PDT 2013" sendToBuses="false">
<routeConfiguredForMessage tag="44"> <stop tag="6420" title="Silver Ave & Revere Ave" />
</routeConfiguredForMessage>
<text>Stop moved across Revere During Construction</text>
</message>
<message id="10222" creator="mlee" startBoundary="1377525600000" startBoundaryStr="Mon, Aug 26 07:00:00 PDT 2013" endBoundary="1382857140000" endBoundaryStr="Sat, Oct 26 23:59:00 PDT 2013" sendToBuses="false">
<routeConfiguredForMessage tag="44"> <stop tag="6420" title="Silver Ave & Revere Ave" />
</routeConfiguredForMessage>
<text>Stop moved across Revere During Construction</text>
</message>
</route>
</body>
表达式
//route[1]
我期望返回第一个route
节点,结果是正确的。但是在尝试选择第一个message
节点时,使用了
//message[1]
返回了多个message
节点而不只是一个。
一开始我以为这是平台的问题,但在Android、桌面Java和几个在线xpath测试工具上进行测试后,我得到了相同的结果。
可能是什么问题呢?