Jump to content

Help parsing this info


DmdFreak

Recommended Posts

I'm trying to do a file_get_contents() on the following URL then parse the info.
http://game.trackmanianations.com/online_game/www_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.

[code]- <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>[/code]

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!
Link to comment
Share on other sites

Does this help

[code]
<?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/>';
    }
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.