Jump to content


Photo

Help parsing this info


  • Please log in to reply
4 replies to this topic

#1 DmdFreak

DmdFreak
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 September 2006 - 09:35 PM

I'm trying to do a file_get_contents() on the following URL then parse the info.
http://game.trackman...serverslist.php
I want to end up with the server name and each of the players that are on at that moment.
I want to then turn around and post this info as live results on my website.

- <server>
  <host>freaksserver2</host> 
- <players>
  <player>Fredrik_Smart</player> 
  <player>Susie2002</player> 
  <player>_milllan_</player> 
  <player>BALTAZAR_</player> 
  <player>ZiLWooD</player> 
  <player>Mr._Flips</player> 
  <player>Ayzblokk</player> 
  <player>Rose_Tattoo</player> 
  </players>
  </server>

When I do the file_get_content() I end up with only the names, but when I insert the same URL straight into the browser, I get a coded active page. If anyone has any idea of another way of getting what I want out of this page it would be great. I'm very new to PHP.

Thanks!


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 25 September 2006 - 09:52 PM

What version PHP?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 DmdFreak

DmdFreak
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 September 2006 - 09:58 PM

Sorry about that. Version 5

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 26 September 2006 - 08:03 AM

Does this help

<?php
$xml = simplexml_load_file('http://game.trackmanianations.com/online_game/www_serverslist.php');

foreach ($xml as $server) {
    echo "<h3> ------ $server->host ------ </h3>";
    foreach ($server->players as $playerlist) {
        if ($playerlist->player)
            foreach ($playerlist->player as $name) {
                echo $name . '<br/>';
            }
        else echo 'No players<br/>';
    }
}
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 DmdFreak

DmdFreak
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 26 September 2006 - 03:17 PM

Totally helped! Thanks a bunch! I can edit it from here to list just the servers I want to list. Many many thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users