title: PHP get values from SimpleXMLElement array
body: <p>I have this:</p>
  
  <pre><code>  [1]=&gt;
  object(SimpleXMLElement)#6 (1) {
    ["@attributes"]=&gt;
    array(14) {
      ["name"]=&gt;
      string(5) "MySQL"
      ["acknowledged"]=&gt;
      string(1) "1"
      ["comments"]=&gt;
      string(1) "1"
      ["current_check_attempt"]=&gt;
      string(1) "1"
      ["downtime"]=&gt;
      string(1) "0"
      ["last_check"]=&gt;
      string(19) "2010-05-01 17:57:00"
      ["markdown_filter"]=&gt;
      string(1) "0"
      ["max_check_attempts"]=&gt;
      string(1) "3"
      ["output"]=&gt;
      string(42) "CRITICAL - Socket timeout after 10 seconds"
      ["perfdata_available"]=&gt;
      string(1) "1"
      ["service_object_id"]=&gt;
      string(3) "580"
      ["state"]=&gt;
      string(8) "critical"
      ["state_duration"]=&gt;
      string(6) "759439"
      ["unhandled"]=&gt;
      string(1) "0"
    }
  }
  </code></pre>
  
  <p>(I used var_dump($child) to generate that)</p>
  
  <p>How do I get the 'name' attribute out of there as a string?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$xml = simplexml_load_string($results);
  
  foreach($xml-&gt;data-&gt;list as $child) {
  var_dump($child);
    echo $child-&gt;getName() . ": " . $child-&gt;name . "&lt;br /&gt;";
    }
  </code></pre>