pengu Posted October 20, 2010 Share Posted October 20, 2010 Hey guys, I'm working on a little image thingy. What I want to do, is use a URL such as , http://steamcommunity.com/profiles/76561197968575517/stats/L4D2/?xml=1 Grab data from it, put the into variables and create an image with the data. I read the tutorial on this website and sort of got stuck.. with external XML files, ALSO this doesn't look like your normal XML file. Here is the code I have thus far.. I got stuck at the 'playerstats' part.. <?php $rss = new SimpleXMLElement('http://steamcommunity.com/profiles/76561197968575517/stats/L4D2/?xml=1', null, true); foreach($rss->xpath('playerstats') as $item) { echo <<<EOF <p> {$item->steamID64} <br /> {$item->hoursPlayed} </p> EOF; } ?> Quote Link to comment Share on other sites More sharing options...
Chris92 Posted October 20, 2010 Share Posted October 20, 2010 What does the XML look like? Quote Link to comment Share on other sites More sharing options...
dreamwest Posted October 20, 2010 Share Posted October 20, 2010 $data = @file_get_contents("http://steamcommunity.com/profiles/76561197968575517/stats/L4D2/?xml=1"); $n_data = new SimpleXmlElement($data, LIBXML_NOCDATA); foreach ($n_data->playerstats->stats as $d) { echo $d->campaign; //etc... } Quote Link to comment Share on other sites More sharing options...
pengu Posted October 21, 2010 Author Share Posted October 21, 2010 Invalid argument supplied for foreach() I'm missing something..? Quote Link to comment Share on other sites More sharing options...
pengu Posted October 21, 2010 Author Share Posted October 21, 2010 Got it using a different method. $xml = simplexml_load_file('http://steamcommunity.com/profiles/' . $id . '/?xml=1'); echo $xml->steamID . "<br />"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.