drsfgwuw61488 2016-09-11 23:59
浏览 95

XML插入变量PHP

i have variable $result contains the xml string as below:

<reversegeocode timestamp="Mon, 12 Sep 16 07:52:44 +0000" attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" querystring="format=xml&lat=30&lon=-95&addressdetails=1">
<result place_id="60369529" osm_type="way" osm_id="21077989" ref="County Road 6042" lat="30.0103064" lon="-95.0042308" boundingbox="30.0030833,30.0158095,-95.005969,-95.0038698">
County Road 6042, Sheeks, Liberty County, Texas, 77336, United States of America
</result>
<addressparts>
<road>County Road 6042</road>
<hamlet>Sheeks</hamlet>
<county>Liberty County</county>
<state>Texas</state>
<postcode>77336</postcode>
<country>United States of America</country>
<country_code>us</country_code>
</addressparts>
</reversegeocode>

I am new in PHP need to insert into variables city (if city not exist city= county), state and zip code tags only which is under <addressparts> tag. All rest data can be ignored. I don't know how to do it

  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部