accessing existing attribute returns null

旧时模样 提交于 2019-12-25 06:59:05

问题


i wrote the below expression to retrieve info from the below xml file, but the returned results is null and index out of bound.

please let me know how to retrieve data from this element:

 <ele k="maxspeed:zone" v="60"/>

expression:

"//node[@lat='53.0337395'] [@lon='8.8489255']/following-sibling/following-   
sibling::ele[1]/@v"

xml:

<?xml version='1.0' encoding='utf-8' ?>
<osm>
<node id="25779111" lat="53.0334062" lon="8.8461545"/>
<node id="25779112" lat="53.0338904" lon="8.846314"/>
<node id="25779119" lat="53.0337395" lon="8.8489255"/>
<tag k="maxspeed" v="30"/>
<tag k="maxspeed:zone" v="yes"/>
<ele k="maxspeed:zone" v="60"/>
<node id="25779114" lat="53.334062" lon="8.841545"/>
<node id="25779117" lat="53.338904" lon="8.84614"/>
<node id="25779110" lat="53.33795" lon="8.489255"/>
<tag k="maxspeed" v="32"/>
<tag k="maxspeed:zone" v="no"/>
</osm>

回答1:


You are almost there - you need to add ::tag[1] to the first following-sibling, like this:

"//node[@lat='53.0337395'] [@lon='8.8489255']/following-sibling::tag[1]/following-sibling::ele[1]/@v"

This retrieves Attribute='v="60"'



来源:https://stackoverflow.com/questions/31743402/accessing-existing-attribute-returns-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!