Hello.
I paid for and downloaded MagicParser because I was very excited by the results that I got from it when I attempted to parse an xml feed. When I parse this feed: http://bingogsv3.bingosys.net/fGetRooms2.php?C=GBP&NW=Foxy in the demo I am presented with different records which are individually represented in a table. Each 'record' appears to be a separate 'room id'- this is great.
My goal is to create a table on my website which features a list of 'bingo rooms' and the 'no. of players' and 'jackpot size' in each. If I could put the information from each demo table record into the table I am creating on my site this would be great. However, when I use the PHP source code generated, information for all of the different records display together.
My question is how can I only display information for a certain 'record/bingo room' e.g. 'ROOM-CURRENTPLAYERS' in 'Room ID 2'. At the moment I get information from all the records.
I am sorry if this situation is difficult to understand.
Thanks
Tom Waite
Marvellous. I'll have a good look at this later.
A great first taste of support too!
Thanks
Tom
Hello Tom,
This is straight forward to do - effectively you are completely in control of what is displayed, because you can return TRUE from myRecordHandler to stop the parser; and before that only display information from the record you're interested in by studying the variables.
As an example that contains various different PHP techniques that you might find useful, I've written a script that lets you select a room, and then on a different page, where the ROOM-ID is include in the URL, the myRecordHandler function will then display the number of players in that room. Here's the output running on this server:
http://www.magicparser.com/examples/bingo.php
And here's the script:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
if ($_GET["roomId"])
{
if ($record["ROOM-ID"] == $_GET["roomId"])
{
print "<p>The number of players in room ".$record["ROOM-ID"]." is ".$record["ROOM-CURRENTPLAYERS"].".</p>";
return TRUE;
}
}
else
{
print "<p><a href='?roomId=".$record["ROOM-ID"]."'>".$record["ROOM-ID"]."</a></p>";
}
}
if (!$_GET["roomId"]) print "<p>Select a room:</p>";
$url = "http://bingogsv3.bingosys.net/fGetRooms2.php?C=GBP&NW=Foxy";
MagicParser_parse($url,"myRecordHandler","xml|ROOT/ROOM/");
?>
Hope this helps!
Regards,
Daivd.