我有一个由 Open Street Map 生成的 xml 文件。其中有“节点”节点和“路”节点。
“node”节点位于文件的顶部,“way”节点位于文件的下方。“节点”节点包含一个点的纬度和经度(作为属性)信息。“路”节点包含组成路的“nd”节点列表。每个“nd”节点的@ref 属性与“节点”的@id 属性相匹配。
我需要为每个 /way/nd/@ref 解析 xml 并从相应的“节点”获取 @latitude 和 @longitude
本质上,我希望有一个方式列表,其中包含每个节点的纬度和经度值。
如果有人可以提供帮助,将不胜感激。我尝试了几十种 xpath 查询组合来尝试使其工作,但似乎无法确定它。
下面是示例 xml,如果有人感兴趣,我这样做是为了将“方式”导入到 drupal 站点,以在 openlayers 地图上绘制“方式”。
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API">
<note>The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history </note>
<meta osm_base="2012-09-12T07:00:02Z"/>
<node id="291435953" lat="50.7468739" lon="7.1563067" version="4" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="291435954" lat="50.7464770" lon="7.1561995" version="2" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="291435955" lat="50.7461387" lon="7.1558430" version="2" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67">
<tag k="highway" v="turning_circle"/>
</node>
<node id="291435956" lat="50.7472300" lon="7.1555832" version="3" timestamp="2012-02-25T15:00:32Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="291435957" lat="50.7462073" lon="7.1544363" version="1" timestamp="2008-08-26T21:58:25Z" changeset="418638" uid="36773" user="bernd1606">
<tag k="created_by" v="JOSM"/>
</node>
<node id="291438870" lat="50.7479387" lon="7.1562447" version="4" timestamp="2012-02-25T15:00:31Z" changeset="10788449" uid="49785" user="mike67">
<tag k="highway" v="turning_circle"/>
</node>
<node id="291438872" lat="50.7476693" lon="7.1540409" version="1" timestamp="2008-08-26T22:05:07Z" changeset="418638" uid="36773" user="bernd1606">
<tag k="created_by" v="JOSM"/>
</node>
<node id="470930364" lat="50.7466304" lon="7.1550088" version="1" timestamp="2009-08-19T10:27:27Z" changeset="2198882" uid="49785" user="mike67"/>
<node id="1212226020" lat="50.7462970" lon="7.1551053" version="1" timestamp="2011-03-21T18:14:35Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226026" lat="50.7461263" lon="7.1552748" version="1" timestamp="2011-03-21T18:14:35Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226027" lat="50.7460993" lon="7.1549555" version="1" timestamp="2011-03-21T18:14:35Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226028" lat="50.7463885" lon="7.1540406" version="1" timestamp="2011-03-21T18:14:35Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226035" lat="50.7460590" lon="7.1549115" version="1" timestamp="2011-03-21T18:14:36Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226040" lat="50.7460307" lon="7.1549335" version="1" timestamp="2011-03-21T18:14:37Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226041" lat="50.7461886" lon="7.1551879" version="1" timestamp="2011-03-21T18:14:37Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226043" lat="50.7460489" lon="7.1552923" version="1" timestamp="2011-03-21T18:14:37Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226044" lat="50.7465142" lon="7.1543804" version="1" timestamp="2011-03-21T18:14:37Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226049" lat="50.7461296" lon="7.1549315" version="1" timestamp="2011-03-21T18:14:38Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226065" lat="50.7461674" lon="7.1552133" version="1" timestamp="2011-03-21T18:14:39Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226068" lat="50.7460541" lon="7.1546925" version="1" timestamp="2011-03-21T18:14:39Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226069" lat="50.7462755" lon="7.1542526" version="1" timestamp="2011-03-21T18:14:39Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226071" lat="50.7461058" lon="7.1548565" version="1" timestamp="2011-03-21T18:14:39Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226087" lat="50.7462284" lon="7.1551919" version="1" timestamp="2011-03-21T18:14:40Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226090" lat="50.7461464" lon="7.1550496" version="1" timestamp="2011-03-21T18:14:40Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226091" lat="50.7465509" lon="7.1541410" version="1" timestamp="2011-03-21T18:14:40Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226104" lat="50.7460048" lon="7.1551556" version="1" timestamp="2011-03-21T18:14:41Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226127" lat="50.7462070" lon="7.1544275" version="1" timestamp="2011-03-21T18:14:43Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226133" lat="50.7461004" lon="7.1550786" version="1" timestamp="2011-03-21T18:14:43Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226142" lat="50.7460609" lon="7.1548346" version="1" timestamp="2011-03-21T18:14:44Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226144" lat="50.7461532" lon="7.1553573" version="1" timestamp="2011-03-21T18:14:44Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226149" lat="50.7460912" lon="7.1548105" version="1" timestamp="2011-03-21T18:14:44Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226165" lat="50.7461320" lon="7.1546332" version="1" timestamp="2011-03-21T18:14:45Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226171" lat="50.7462548" lon="7.1549671" version="1" timestamp="2011-03-21T18:14:45Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226180" lat="50.7460253" lon="7.1549160" version="1" timestamp="2011-03-21T18:14:46Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226184" lat="50.7462552" lon="7.1552743" version="1" timestamp="2011-03-21T18:14:46Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226192" lat="50.7461445" lon="7.1552153" version="1" timestamp="2011-03-21T18:14:47Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226196" lat="50.7460206" lon="7.1547882" version="1" timestamp="2011-03-21T18:14:47Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226197" lat="50.7461830" lon="7.1548005" version="1" timestamp="2011-03-21T18:14:47Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1212226208" lat="50.7465204" lon="7.1542470" version="1" timestamp="2011-03-21T18:14:48Z" changeset="7630016" uid="49785" user="mike67"/>
<node id="1558201806" lat="50.7465619" lon="7.1543799" version="1" timestamp="2011-12-22T14:11:53Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201807" lat="50.7465706" lon="7.1545076" version="1" timestamp="2011-12-22T14:11:53Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201808" lat="50.7465787" lon="7.1542431" version="1" timestamp="2011-12-22T14:11:53Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201809" lat="50.7465945" lon="7.1546459" version="1" timestamp="2011-12-22T14:11:53Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201810" lat="50.7466379" lon="7.1540966" version="1" timestamp="2011-12-22T14:11:53Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201813" lat="50.7468171" lon="7.1569205" version="1" timestamp="2011-12-22T14:11:54Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1558201814" lat="50.7469049" lon="7.1557857" version="2" timestamp="2012-02-25T15:00:33Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="1558201822" lat="50.7472431" lon="7.1542901" version="2" timestamp="2012-02-25T15:00:31Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="1558201829" lat="50.7478716" lon="7.1567219" version="1" timestamp="2011-12-22T14:11:54Z" changeset="10179910" uid="116044" user="berndw"/>
<node id="1579451712" lat="50.7475476" lon="7.1550423" version="2" timestamp="2012-02-25T15:00:32Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="1647096049" lat="50.7477273" lon="7.1555526" version="1" timestamp="2012-02-25T15:00:31Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="1647096076" lat="50.7468682" lon="7.1556378" version="1" timestamp="2012-02-25T15:00:32Z" changeset="10788449" uid="49785" user="mike67"/>
<node id="1647096079" lat="50.7469025" lon="7.1560030" version="2" timestamp="2012-05-13T23:29:39Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="1751820951" lat="50.7469115" lon="7.1558916" version="1" timestamp="2012-05-13T23:29:39Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="1751820952" lat="50.7465981" lon="7.1562371" version="1" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="1751820953" lat="50.7463604" lon="7.1561245" version="1" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="1751820954" lat="50.7462630" lon="7.1560233" version="1" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<node id="1751820955" lat="50.7461938" lon="7.1559261" version="1" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67"/>
<way id="26577114" version="3" timestamp="2012-05-13T23:29:40Z" changeset="11591622" uid="49785" user="mike67">
<nd ref="291435953"/>
<nd ref="1751820952"/>
<nd ref="291435954"/>
<nd ref="1751820953"/>
<nd ref="1751820954"/>
<nd ref="1751820955"/>
<nd ref="291435955"/>
<tag k="highway" v="residential"/>
<tag k="lit" v="yes"/>
<tag k="name" v="Rhedenstraße"/>
</way>
<way id="26577115" version="2" timestamp="2011-12-22T14:12:55Z" changeset="10179910" uid="116044" user="berndw">
<nd ref="1558201814"/>
<nd ref="291435956"/>
<tag k="highway" v="residential"/>
<tag k="name" v="Von-Ketteler-Straße"/>
</way>
<way id="26577275" version="4" timestamp="2012-02-25T15:00:32Z" changeset="10788449" uid="49785" user="mike67">
<nd ref="291438870"/>
<nd ref="1647096049"/>
<nd ref="1579451712"/>
<nd ref="1558201822"/>
<nd ref="1558201815"/>
<tag k="highway" v="residential"/>
<tag k="name" v="Mutter-Barat-Straße"/>
</way>
<way id="26577276" version="3" timestamp="2012-02-25T15:00:30Z" changeset="10788449" uid="49785" user="mike67">
<nd ref="291438871"/>
<nd ref="291438872"/>
<nd ref="1647095991"/>
<nd ref="1647095994"/>
<nd ref="291438873"/>
<tag k="highway" v="residential"/>
<tag k="lit" v="yes"/>
<tag k="name" v="Stegerwaldstraße"/>
</way>
<way id="31347483" version="6" timestamp="2012-02-25T14:04:08Z" changeset="10787922" uid="49785" user="mike67">
<nd ref="1558201825"/>
<nd ref="96133774"/>
<nd ref="1647008854"/>
<nd ref="1558201826"/>
<nd ref="1558201827"/>
<nd ref="96133775"/>
<nd ref="1558201829"/>
<nd ref="1558201831"/>
<nd ref="96133776"/>
<nd ref="1558201832"/>
<nd ref="291438874"/>
<nd ref="1558201836"/>
<nd ref="96133777"/>
<nd ref="291089398"/>
<nd ref="96133778"/>
<nd ref="32346787"/>
<nd ref="291089396"/>
<nd ref="291092263"/>
<nd ref="33078442"/>
<tag k="highway" v="residential"/>
<tag k="lit" v="yes"/>
<tag k="name" v="Alte Schulstraße"/>
</way>
<way id="39300712" version="3" timestamp="2011-10-30T13:18:29Z" changeset="9693579" uid="239847" user="theophrastus">
<nd ref="470930364"/>
<nd ref="1212226113"/>
<nd ref="470930365"/>
<tag k="name" v="Alaunbach"/>
<tag k="waterway" v="stream"/>
</way>
<way id="105196611" version="2" timestamp="2011-05-26T14:50:40Z" changeset="8254295" uid="49785" user="mike67">
<nd ref="1212226149"/>
<nd ref="1212226142"/>
<nd ref="1212226027"/>
<nd ref="1212226049"/>
<nd ref="1212226071"/>
<nd ref="1212226149"/>
<tag k="building" v="garages"/>
</way>
<way id="105196614" version="1" timestamp="2011-03-21T18:14:50Z" changeset="7630016" uid="49785" user="mike67">
<nd ref="1212226065"/>
<nd ref="1212226220"/>
<tag k="highway" v="service"/>
</way>
<way id="105196615" version="2" timestamp="2011-03-21T18:21:18Z" changeset="7630100" uid="49785" user="mike67">
<nd ref="1212226068"/>
<nd ref="1212226149"/>
<nd ref="1212226071"/>
<nd ref="1212226197"/>
<nd ref="1212226165"/>
<nd ref="1212226068"/>
<tag k="addr:city" v="Bonn"/>
<tag k="addr:country" v="DE"/>
<tag k="addr:housenumber" v="21a"/>
<tag k="addr:postcode" v="53229"/>
<tag k="addr:street" v="Von-Ketteler-Straße"/>
<tag k="building" v="yes"/>
</way>
<way id="105196617" version="2" timestamp="2011-03-21T18:21:18Z" changeset="7630100" uid="49785" user="mike67">
<nd ref="1212226067"/>
<nd ref="1212226047"/>
<nd ref="1212226166"/>
<nd ref="1212226180"/>
<nd ref="1212226130"/>
<nd ref="1212226067"/>
<tag k="addr:city" v="Bonn"/>
<tag k="addr:country" v="DE"/>
<tag k="addr:housenumber" v="23"/>
<tag k="addr:postcode" v="53229"/>
<tag k="addr:street" v="Von-Ketteler-Straße"/>
<tag k="building" v="yes"/>
</way>
<way id="105196618" version="2" timestamp="2011-03-21T20:19:24Z" changeset="7631407" uid="49785" user="mike67">
<nd ref="1212226110"/>
<nd ref="1212226181"/>
<nd ref="1212226107"/>
<nd ref="1212226030"/>
<nd ref="1212226125"/>
<nd ref="1212226091"/>
<nd ref="1212226208"/>
<nd ref="1212226044"/>
<nd ref="1212226127"/>
<nd ref="1212226203"/>
<nd ref="1212226085"/>
<nd ref="1212226052"/>
<nd ref="1212226042"/>
<nd ref="1212226061"/>
<nd ref="1212226038"/>
<nd ref="1212226190"/>
<nd ref="1212226139"/>
<nd ref="1212226110"/>
<tag k="amenity" v="school"/>
<tag k="name" v="Marktschule"/>
</way>
<way id="105196620" version="2" timestamp="2011-05-26T14:50:40Z" changeset="8254295" uid="49785" user="mike67">
<nd ref="1212226196"/>
<nd ref="1212226130"/>
<nd ref="1212226180"/>
<nd ref="1212226040"/>
<nd ref="1212226035"/>
<nd ref="1212226196"/>
<tag k="building" v="garages"/>
</way>
<way id="105196621" version="2" timestamp="2011-03-21T18:21:17Z" changeset="7630100" uid="49785" user="mike67">
<nd ref="1212226041"/>
<nd ref="1212226090"/>
<nd ref="1212226171"/>
<nd ref="1212226020"/>
<nd ref="1212226041"/>
<tag k="addr:city" v="Bonn"/>
<tag k="addr:country" v="DE"/>
<tag k="addr:housenumber" v="23a"/>
<tag k="addr:postcode" v="53229"/>
<tag k="addr:street" v="Von-Ketteler-Straße"/>
<tag k="building" v="yes"/>
</way>
<way id="105196625" version="2" timestamp="2011-03-21T18:21:18Z" changeset="7630100" uid="49785" user="mike67">
<nd ref="1212226133"/>
<nd ref="1212226104"/>
<nd ref="1212226043"/>
<nd ref="1212226192"/>
<nd ref="1212226133"/>
<tag k="addr:city" v="Bonn"/>
<tag k="addr:country" v="DE"/>
<tag k="addr:housenumber" v="23b"/>
<tag k="addr:postcode" v="53229"/>
<tag k="addr:street" v="Von-Ketteler-Straße"/>
<tag k="building" v="yes"/>
</way>
<way id="105196626" version="1" timestamp="2011-03-21T18:14:54Z" changeset="7630016" uid="49785" user="mike67">
<nd ref="1212226028"/>
<nd ref="1212226024"/>
<nd ref="1212226031"/>
<nd ref="1212226159"/>
<nd ref="1212226131"/>
<nd ref="1212226069"/>
<nd ref="1212226028"/>
<tag k="building" v="yes"/>
<tag k="leisure" v="sports_centre"/>
<tag k="sport" v="multi"/>
</way>
<way id="105196629" version="2" timestamp="2011-05-26T14:50:40Z" changeset="8254295" uid="49785" user="mike67">
<nd ref="1212226087"/>
<nd ref="1212226026"/>
<nd ref="1212226144"/>
<nd ref="1212226184"/>
<nd ref="1212226087"/>
<tag k="building" v="garages"/>
</way>
<way id="142380554" version="1" timestamp="2011-12-22T14:11:57Z" changeset="10179910" uid="116044" user="berndw">
<nd ref="1558201831"/>
<nd ref="291438870"/>
<tag k="highway" v="footway"/>
<tag k="name" v="Mutter-Barat-Straße"/>
</way>
<way id="142380557" version="3" timestamp="2012-05-13T23:29:39Z" changeset="11591622" uid="49785" user="mike67">
<nd ref="1558201823"/>
<nd ref="1558201815"/>
<nd ref="1558201810"/>
<nd ref="1558201808"/>
<nd ref="1558201806"/>
<nd ref="1558201807"/>
<nd ref="1558201809"/>
<nd ref="1647096076"/>
<nd ref="1558201814"/>
<nd ref="1751820951"/>
<nd ref="1647096079"/>
<nd ref="291435953"/>
<nd ref="1558201813"/>
<nd ref="1558201812"/>
<tag k="highway" v="residential"/>
<tag k="lit" v="yes"/>
<tag k="name" v="Von-Ketteler-Straße"/>
</way>
<way id="142380558" version="1" timestamp="2011-12-22T14:11:58Z" changeset="10179910" uid="116044" user="berndw">
<nd ref="1558201806"/>
<nd ref="291435957"/>
<nd ref="1212226220"/>
<nd ref="291435958"/>
<nd ref="291435959"/>
<nd ref="1212226021"/>
<tag k="bicycle" v="yes"/>
<tag k="foot" v="yes"/>
<tag k="highway" v="service"/>
<tag k="motorcar" v="private"/>
<tag k="motorcycle" v="private"/>
<tag k="name" v="Von-Ketteler-Straße"/>
</way>
</osm>