title: XML to insert variables PHP
body: <p>i have variable <code>$result</code> contains the xml string as below:</p>
  
  <pre><code>&lt;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&amp;lat=30&amp;lon=-95&amp;addressdetails=1"&gt;
  &lt;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"&gt;
  County Road 6042, Sheeks, Liberty County, Texas, 77336, United States of America
  &lt;/result&gt;
  &lt;addressparts&gt;
  &lt;road&gt;County Road 6042&lt;/road&gt;
  &lt;hamlet&gt;Sheeks&lt;/hamlet&gt;
  &lt;county&gt;Liberty County&lt;/county&gt;
  &lt;state&gt;Texas&lt;/state&gt;
  &lt;postcode&gt;77336&lt;/postcode&gt;
  &lt;country&gt;United States of America&lt;/country&gt;
  &lt;country_code&gt;us&lt;/country_code&gt;
  &lt;/addressparts&gt;
  &lt;/reversegeocode&gt;
  </code></pre>
  
  <p>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 <code>&lt;addressparts&gt;</code> tag. All rest data can be ignored. I don't know how to do it </p>