Welcome to Geeklog, Anonymous Wednesday, April 17 2024 @ 11:45 am EDT

Geeklog Forums

XML/RSS feed is not working


I have a rss/xml feed from my counter-strike game server and its suppose to spit out the server status, but when i make a new block for it, set it a phpportal and add the url feed nothing is showing up. can anyone help plz?

my xml/rss feed is http://www.serverspy.net/bin/smonXml.mpl?mid=36508
(its doesnt have the xml/rss file type but it seems to be working for other sites.)

Status: offline


Site Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by JC_Lopez:http://www.serverspy.net/bin/smonXml.mpl?mid=36508
(its doesnt have the xml/rss file type but it seems to be working for other sites.)

Geeklog doesn't care about the extension - it simply tries to read the file with an XML parser.

However, it expects to find "title" and "link" items in a feed, but the above feed doesn't have any. Not sure what this is being used for, but it's not a normal news feed.

I guess it would be possible to write a PHP block that does whatever's supposed to be done with this feed, though.

bye, Dirk


Text Formatted Code

// Simple script to print out a very basic server status page using the ServerSpy.net Monitor xml
// Use this code in a 'block' on php-Nuke websites. Should also work as a simple webpage for
// others that have php/xml support.
// Tutorial for XML/PHP http://www.webmasterbase.com/article/560
// This PHP script is developed as an example method of retrieving ServerSPy data via XML

$smonXML = 'http://www.serverspy.net/bin/smonXml.mpl?mid=25301';
// This is the XML URL of the servermonitor you wish to query.

// Scroll down to amend the HTML output to the style you wish to achieve.

$smon = Array();
global $smon;
$smon['PLAYERS'] = Array();
$smon['DETAILS'] = Array();
$smon['RULES'] = Array();
$smon['SERVERSPY'] = Array();

function startElement($parser, $tagName, $attrs) {
        global $smon;
        if ($tagName == 'PLAYERS'){
                $smon['PLAYERS'][$attrs['NAME']] = Array();
                $smon['PLAYERS'][$attrs['NAME']]['CONNECTED'] = $attrs['CONNECTED'];
                $smon['PLAYERS'][$attrs['NAME']]['KILLS'] = $attrs['KILLS'];

        } elseif ($tagName == 'SERVERSPY'){
                $smon['SERVERSPY'][$attrs['NAME']] = $attrs['VALUE'];

        } elseif ($tagName == 'RULES'){
                $smon['RULES'][$attrs['NAME']] = $attrs['VALUE'];
        } elseif ($tagName == 'DETAILS'){
                $smon['DETAILS'][$attrs['NAME']] = $attrs['VALUE'];

//      while (list ($key, $val) = each ($attrs)) {
//      } // end while

function characterData($parser, $data) {    
        // no wrapped data used

function endElement($parser, $tagName) {    
        // no wrapped data used

// Create an XML parser
$xml_parser = xml_parser_create();

// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");

// Set the function to handle blocks of character data
xml_set_character_data_handler($xml_parser, "characterData");

// Open the XML file for reading
$fp = fopen($smonXML,"r")  or die("Error reading ServerSpy.net XML feed. Either the URL is invalid or the XML feed has been updated.");

// Read the XML file 4KB at a time
while ($data = fread($fp, 4096))    
// Parse each 4KB chunk with the XML parser created above
xml_parse($xml_parser, $data, feof($fp))
                or die(sprintf("XML error: %s at line %d",
// Close the XML filef

// Free up memory used by the XML parser

wuld you know how to create a php block? i never made one b4
thank you for your reply earlier

All times are EDT. The time is now 11:45 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content