title: Get value from SimpleXMLElement Object
body: <p>I have something like this:</p>
  
  <pre><code>$url = "http://ws.geonames.org/findNearbyPostalCodes?country=pl&amp;placename=";
  $url .= rawurlencode($city[$i]);
  
  $xml = simplexml_load_file($url);
  echo $url."\n";
  $cityCode[] = array(
      'city' =&gt; $city[$i], 
      'lat' =&gt; $xml-&gt;code[0]-&gt;lat, 
      'lng' =&gt; $xml-&gt;code[0]-&gt;lng
  );
  </code></pre>
  
  <p>It's supposed to download XML from geonames. If I do <code>print_r($xml)</code> I get : </p>
  
  <pre><code>SimpleXMLElement Object
  (
      [code] =&gt; Array
          (
              [0] =&gt; SimpleXMLElement Object
                  (
                      [postalcode] =&gt; 01-935
                      [name] =&gt; Warszawa
                      [countryCode] =&gt; PL
                      [lat] =&gt; 52.25
                      [lng] =&gt; 21.0
                      [adminCode1] =&gt; SimpleXMLElement Object
                          (
                          )
  
                      [adminName1] =&gt; Mazowieckie
                      [adminCode2] =&gt; SimpleXMLElement Object
                          (
                          )
  
                      [adminName2] =&gt; Warszawa
                      [adminCode3] =&gt; SimpleXMLElement Object
                          (
                          )
  
                      [adminName3] =&gt; SimpleXMLElement Object
                          (
                          )
  
                      [distance] =&gt; 0.0
                  )
  </code></pre>
  
  <p>I do as you can see <code>$xml-&gt;code[0]-&gt;lat</code> and it returns an object. How can i get the value? </p>