title: PHP SimpleXML + Get Attribute
body: <p>The XML I am reading looks like this:</p>
  
  <pre><code>&lt;show id="8511"&gt;
  
      &lt;name&gt;The Big Bang Theory&lt;/name&gt;
      &lt;link&gt;http://www.tvrage.com/The_Big_Bang_Theory&lt;/link&gt;
      &lt;started&gt;2007-09-24&lt;/started&gt;
      &lt;country&gt;USA&lt;/country&gt;
  
      &lt;latestepisode&gt;
          &lt;number&gt;05x23&lt;/number&gt;
          &lt;title&gt;The Launch Acceleration&lt;/title&gt;
      &lt;/latestepisode&gt;
  
  &lt;/show&gt;
  </code></pre>
  
  <p>To get (for example) The number of the latest episode, I would do:</p>
  
  <pre><code>$ep = $xml-&gt;latestepisode[0]-&gt;number;
  </code></pre>
  
  <p>This works just fine. But what would I do to get the ID from <code>&lt;show id="8511"&gt;</code> ?</p>
  
  <p>I have tried something like:</p>
  
  <pre><code>$id = $xml-&gt;show;
  $id = $xml-&gt;show[0];
  </code></pre>
  
  <p>But none worked.</p>
  
  <p><strong>Update</strong></p>
  
  <p>My code snippet:</p>
  
  <pre><code>$url    = "http://services.tvrage.com/feeds/episodeinfo.php?show=".$showName;
  $result = file_get_contents($url);
  $xml = new SimpleXMLElement($result);
  
  //still doesnt work
  $id = $xml-&gt;show-&gt;attributes()-&gt;id;
  
  $ep = $xml-&gt;latestepisode[0]-&gt;number;
  
  echo ($id);
  </code></pre>
  
  <p>Ori. XML:</p>
  
  <pre><code>http://services.tvrage.com/feeds/episodeinfo.php?show=The.Big.Bang.Theory
  </code></pre>