RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

XML Page Parser

Nott32

Wanderer
XML Page Parser

This is a script I found earlier that will parse XML files into a nice list... I modified it for use with the consti GamerTag script. I use it on my new site to display information then I use another script to parse the page...

I use it with 360voice.com API.

PHP:
<?php
// http://www.nottnetworks.com/gamertag/
// A Nott32 script (http://www.nottnetworks.com)
 

//Requires the Consti GamerTag script: http://consti.de/external/gamercard/
include 'gamercard.php'; //Used so the system can use the $tag

//Parses the 360Voice.com Leaderboard for specified tag (XML) 
//Change the URL to whatever the XML document is
//For the 360voice.com API list go to http://360voice.wetpaint.com/page/API
$file = 'http://www.360voice.com/api/gamertag-leaderboard.asp?tag='.$tag; //Page to Parse

function contents($parser, $data){ 
    echo $data; 
} 

function startTag($parser, $data){ 
    echo '<b>';  
} 

function endTag($parser, $data){ 
    echo '</b><br />'; 
} 

$xml_parser = xml_parser_create(); 

xml_set_element_handler($xml_parser, 'startTag', 'endTag'); 

xml_set_character_data_handler($xml_parser, 'contents'); 

$fp = fopen($file, 'r'); 

$data = fread($fp, 80000); 

if(!(xml_parse($xml_parser, $data, feof($fp)))){ 
    die('Error on line ' . xml_get_current_line_number($xml_parser));
} 

xml_parser_free($xml_parser); 

fclose($fp); 

?>
 
Top