View Full Version : reading RSS from gamebattles-need help with script

the game hog
11-15-2007, 01:07 AM
I am not to good with reading file contents using PHP, so instead of spending hours on the web, I found a site that provides code for an RSS reader in PHP and I am having some trouble with it.

The site is located here (this page includes the coding anyway):

The page I am trying to get the RSS feeds from is here:

Gamebattles provides detailed stats to the raw bone on their site now, but I don't know how to retrieve them... should I even use this script or can I write something simple?
First off, I am trying to get JUST the names of all the players, I modified the coding provided by the site to try to get it to work based on the RSS tags, but no hope. Heres the code:


$insideitem = false;
$tag = "";
$name = "";

function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $name;
if ($insideitem) {
$tag = $name;
} elseif ($name == "PLAYER") {
$insideitem = true;

function endElement($parser, $name) {
global $insideitem, $tag, $name;
if ($name == "PLAYER") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
$name = "";
$insideitem = false;

function characterData($parser, $data) {
global $insideitem, $tag, $name;
if ($insideitem) {
switch ($tag) {
case "NAME":
$name .= $data;

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://www.gamebattles.com/xbox360/halo3/team/PERFECTALLIANCE/stats.xml","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",


Beyond this (if I can get this to work), I would also like to figure out how to retrieve the matches and stuff, but it's very confusing for me. I am good with PHP, but I have trouble when it comes to things like this, it doesn't make sense to me how its setting everything first and then it reads the file at the end.
I try the script out, and it doesn't display anything. It's not getting the results from the news feed. I don't know what else to do. Is there a simple fix or am I missing something that will make it run?
If someone could help me with this, I would really appreciate it and so would the gamers on the clan site I am using this one for! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum