title: How to Get value from SimpleXMLElement Object
body: <p>I am writing that post because i'm trying to solve a problem which seems to be stupid but unfortunately i cannot make it. I have an XML file (link) which i'm parsing with simplexml_load_string($link) as below:</p>
  
  <pre><code>$response_xml_data = file_get_contents($link);
  $xml = simplexml_load_string($response_xml_data);
  foreach ($xml-&gt;item as $licenseElement) {
      $title = $licenseElement-&gt;title;
      echo $title;
  }
  </code></pre>
  
  <p>I need to get value of <code>title</code> and <code>link</code> but no any result.</p>
  
  <p>I try to print <code>$link</code> and show me this :</p>
  
  <pre><code>SimpleXMLElement Object
      (
          [@attributes] =&gt; Array
              (
                  [version] =&gt; 2.0
              )
  
          [channel] =&gt; SimpleXMLElement Object
              (
                  [title] =&gt; GamePlay
                  [link] =&gt; https://example.com/
                  [description] =&gt; The latest blog posts from example.com.
                  [language] =&gt; en-us
                  [pubDate] =&gt; Mon, 14 Nov 2016 18:50:50 +0000
                  [lastBuildDate] =&gt; Mon, 14 Nov 2016 18:50:50 +0000
                  [managingEditor] =&gt; info@example.com
                  [item] =&gt; SimpleXMLElement Object
                      (
                          [title] =&gt; IO Interactive 
                          [link] =&gt; http://example.com/?p=258
                      )
  
              )
  
      )
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  When try to var_dump($xml); before loop :</p>
  
  <pre><code>object(SimpleXMLElement)#2568 (2) {
    ["@attributes"]=&gt;
    array(1) {
      ["version"]=&gt;
      string(3) "2.0"
    }
    ["channel"]=&gt;
    object(SimpleXMLElement)#2571 (8) {
      ["title"]=&gt;
      string(8) "Gameplay"
      ["link"]=&gt;
      string(21) "https://example.com/"
      ["description"]=&gt;
      string(40) "The latest blog posts from example.com."
      ["language"]=&gt;
      string(5) "en-us"
      ["pubDate"]=&gt;
      string(31) "Mon, 14 Nov 2016 19:08:33 +0000"
      ["lastBuildDate"]=&gt;
      string(31) "Mon, 14 Nov 2016 19:08:33 +0000"
      ["managingEditor"]=&gt;
      string(17) "info@example.com"
      ["item"]=&gt;
      object(SimpleXMLElement)#2574 (2) {
        ["title"]=&gt;
        string(76) "IO Interactive "
        ["link"]=&gt;
        string(217) "http://example.com/?p=258"
      }
    }
  }
  </code></pre>