So I'm just trying to parse an XML file with SimpleXML. I can access most of the items and parse them correctly but the GamerScore one is giving me trouble and always returning a 0. The GamerScore I am interested in is the first item, in my example it's value is 2090. Please Help 🙁
Link to the XML: http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=OcR%20Envy
My Code:
<?php
function screen_scrape ($link)
{
require_once(dirname(__FILE__).'/class_http.php');
$h = new http();
$h->dir = "/cache/";
if (!$h->fetch($link,600))
{
echo "<h2>There is a problem with the http request!</h2>";
echo $h->log; exit();
}
$newhtml=$h->body;
return $newhtml;
}
$h3tag = $_GET['h3tag'];
$h3tag = str_replace(" ","%20",$h3tag);
$fetch_url = "http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=" . urlencode($h3tag);
$userinfo=screen_scrape("$fetch_url");
$xml = simplexml_load_string($userinfo);
$score=$xml->GamerScore;
echo $score;
?>