title: How to iterate through XML values that are a SimpleXMLElement Object
body: <p>I have an XML stream parsed to a SimpleXMLElement Object and I am trying to iterate though the available records to use as values in a PHP page.</p>
  
  <p>The parent node of [listing] currently exists twice as there are two records in the test XML (listing[0] and listing[1])
  But I can not get this to work like shown on the "Basic SimpleXML usage" from the PHP Manual</p>
  
  <pre><code>    &lt;?php
      $xml = simplexml_load_file('http://feed.postlets.com/Burndog/6458ec1af54f632');
  </code></pre>
  
  <p>This works to provide the first listing title element value:</p>
  
  <pre><code>    $value1 = $xml-&gt;listing[0]-&gt;title;
      echo ' here:' . $value1;
  </code></pre>
  
  <p>This fails to iterate through the available values:</p>
  
  <pre><code>    foreach ($xml-&gt;listing-&gt;title as $title) {
      echo $title;
      }
      ?&gt;
  </code></pre>
  
  <p>values from a print_r:</p>
  
  <pre><code>SimpleXMLElement Object
  (
  [listing] =&gt; Array
      (
          [0] =&gt; SimpleXMLElement Object
              (
                  [url] =&gt; http://www.postlets.com/repb/6509636
                  [title] =&gt; 3BR/2BA Manufactured - Beaumont
                  [subtitle] =&gt; SimpleXMLElement Object
                      (
                      )
  
                  [description] =&gt; SimpleXMLElement Object
                      (
                      )
  
                  [location] =&gt; SimpleXMLElement Object
                      (
                          [street] =&gt; 1415 E 6th St
                          [city] =&gt; Beaumont
                          [zipcode] =&gt; 92223
                          [state] =&gt; CA
                          [latitude] =&gt; 33.928326
                          [longitude] =&gt; -116.959923
                          [walkscore] =&gt; 46
                      )
  
                  [details] =&gt; SimpleXMLElement Object
                      (
                          [money] =&gt; SimpleXMLElement Object
                              (
                                  [price] =&gt; 44900
                              )
  
                          [property_for] =&gt; Sale
                          [property_use] =&gt; Residential
                          [property_type] =&gt; Manufactured
                          [year_built] =&gt; 2011
                          [bedrooms] =&gt; 3
                          [full_bathrooms] =&gt; 2
                          [partial_bathrooms] =&gt; 0
                          [sqft] =&gt; 1041
                          [lot_size] =&gt; 1045 sqft
                          [parking] =&gt; SimpleXMLElement Object
                              (
                              )
  
                      )
  
                  [photos] =&gt; SimpleXMLElement Object
                      (
                          [photo_1] =&gt; http://www.postlets.com/create/photos/20111101/082821_6509636_158803034.jpg
                          [photo_caption_1] =&gt; Photo 1
                          [photo_2] =&gt; http://www.postlets.com/create/photos/20111101/082822_6509636_3416721218.jpg
                          [photo_caption_2] =&gt; Photo 2
                          [photo_3] =&gt; http://www.postlets.com/create/photos/20111101/082822_6509636_1298858591.jpg
                          [photo_caption_3] =&gt; Photo 3
                      )
  
                  [contact] =&gt; SimpleXMLElement Object
                      (
  
                      )
  
              )
  
          [1] =&gt; SimpleXMLElement Object
              (
                  [url] =&gt; http://www.postlets.com/repb/7066849
                  [title] =&gt; 2BR/1+1BA Manufactured - Beaumont
                  [subtitle] =&gt; SimpleXMLElement Object
                      (
                      )
  
                  [description] =&gt; SimpleXMLElement Object
                      (
                      )
  
                  [location] =&gt; SimpleXMLElement Object
                      (
                          [street] =&gt; 1415 E 6th St # 12
                          [city] =&gt; Beaumont
                          [zipcode] =&gt; 92223
                          [state] =&gt; CA
                          [latitude] =&gt; 33.929199
                          [longitude] =&gt; -116.959831
                          [walkscore] =&gt; 46
                      )
  
                  [details] =&gt; SimpleXMLElement Object
                      (
                          [money] =&gt; SimpleXMLElement Object
                              (
                                  [price] =&gt; 56000
                                  [hoa] =&gt; 400
                              )
  
                          [property_for] =&gt; Sale
                          [property_use] =&gt; Residential
                          [property_type] =&gt; Manufactured
                          [year_built] =&gt; 1997
                          [bedrooms] =&gt; 2
                          [full_bathrooms] =&gt; 1
                          [partial_bathrooms] =&gt; 1
                          [sqft] =&gt; 1250
                          [lot_size] =&gt; 3000 sqft
                          [property_features] =&gt; Central A/C, Dining room, Breakfast nook, Dryer
                          [community_features] =&gt; Covered parking
                          [parking] =&gt; SimpleXMLElement Object
                              (
                              )
  
                      ) etc etc
  </code></pre>
  
  <p>Then what will it take to loop through the elements for pictures as there is more than one?
  Thanks!</p>