title: Reading Steam Web API with simplexml and PHP
body: <p>So I've read a couple of topics on reading XML with simpleXML, but I'm having troubles with my specific case.</p>
  
  <p>Currently I am trying to extract single values from this XML block that comes from a Steam web API URL</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE response&gt;
  &lt;response&gt;
    &lt;players&gt;
      &lt;player&gt;
          &lt;steamid&gt;76561197996635228&lt;/steamid&gt;
          &lt;communityvisibilitystate&gt;3&lt;/communityvisibilitystate&gt;
          &lt;profilestate&gt;1&lt;/profilestate&gt;
          &lt;personaname&gt;P337&lt;/personaname&gt;
          &lt;lastlogoff&gt;1386990920&lt;/lastlogoff&gt;
          &lt;commentpermission&gt;1&lt;/commentpermission&gt;
          &lt;profileurl&gt;http://steamcommunity.com/id/P337/&lt;/profileurl&gt;
          &lt;avatar&gt;http://media.steampowered.com/steamcommunity/public/images/avatars/43/438f1b6217ee5600772cd1f9d978fbba999d8cc6.jpg&lt;/avatar&gt;
          &lt;avatarmedium&gt;http://media.steampowered.com/steamcommunity/public/images/avatars/43/438f1b6217ee5600772cd1f9d978fbba999d8cc6_medium.jpg&lt;/avatarmedium&gt;
          &lt;avatarfull&gt;http://media.steampowered.com/steamcommunity/public/images/avatars/43/438f1b6217ee5600772cd1f9d978fbba999d8cc6_full.jpg&lt;/avatarfull&gt;
          &lt;personastate&gt;0&lt;/personastate&gt;
          &lt;primaryclanid&gt;103582791431212131&lt;/primaryclanid&gt;
          &lt;timecreated&gt;1203124452&lt;/timecreated&gt;
          &lt;personastateflags&gt;0&lt;/personastateflags&gt;
      &lt;/player&gt;
    &lt;/players&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>and I can output all of this to a web page with the following PHP code (code has come from another post, which was incredibly helpful</p>
  
  <pre><code>$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=[STEAMAPIKEY]&amp;steamids=[PROFILEID]&amp;format=xml";
  $get = file_get_contents($url);
  $xml = simplexml_load_string($get);
  
  header('Content-Type: text/xml');
  die($xml-&gt;asXML());
  </code></pre>
  
  <p>However when I attempt to change $xml->asXML() to another element like the documentation says to, like so:</p>
  
  <pre><code>echo '&lt;p&gt;'.$xml-&gt;response-&gt;players-&gt;player-&gt;personastate.'&lt;/p&gt;;
  </code></pre>
  
  <p>I get an error saying that there is no data returned.</p>
  
  <p>For the purpose of the example I am trying to retrieve the element <code>&lt;personastate&gt;</code> which indicates if the player is online or not.</p>