0
我想了解如何設置XPath,以幫助我在以下文件中找到serialdata
的值,僅當serialname
是'Motion'
時。XPATH語法幫助 - 根據同級值獲取價值
我想根據給定節點的值獲取兄弟節點的值。
<file>
<error>0</error>
<gls>
<mtsn>123</mtsn>
<asset>
<assetid>n/a</assetid>
<assettype>None</assettype>
<owner>My Company</owner>
</asset>
<messagetype>Event</messagetype>
<binary>
<inputname>Tether</inputname>
<inputid>15</inputid>
<event>E</event>
<inputval>1</inputval>
<inputstate>Tether</inputstate>
<timeofreading>2014/01/22 16:50:30</timeofreading>
</binary>
<extpwr>0</extpwr>
<serial>
<serialtype>2</serialtype>
<serialid>3</serialid>
<serialname>Motion</serialname>
<serialdata>Idle</serialdata>
</serial>
<serial>
<serialtype>2</serialtype>
<serialid>5</serialid>
<serialname>Cargo</serialname>
<serialdata>No answer</serialdata>
</serial>
<latitude>40.40299</latitude>
<longitude>-86.85927</longitude>
<battery>OK</battery>
<time>2014/01/22 16:50:30</time>
<quality>0</quality>
<landmark>
<geoname>Lafayette</geoname>
<state>IN</state>
<country>US</country>
<distance>0.81</distance>
<direction>SE</direction>
<geotypename>GENERIC</geotypename>
</landmark>
<skyfence>
<skyfencestatus>n/a</skyfencestatus>
</skyfence>
<epmflag>0</epmflag>
<transid>21722229</transid>
</gls>
</file>
井的XML沒有正確發佈。不知道如何做到這一點。 – user1224074
我相信它可能是:/ file/gls/serial [serialname ='Motion']/serialdata/text() – user1224074
你可以在這裏測試xpath http://www.xpathtester.com/test – hemanth