0

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

Vitali
  • 95
  • 1
  • 1
  • 6
  • http://php.net/manual/en/book.simplexml.php is a good read on this. – apokryfos Sep 12 '16 at 08:00
  • 5
    Possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – user3942918 Sep 12 '16 at 08:02

0 Answers0