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