Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/02/2010, 01:41
Avatar de xalupeao
xalupeao
 
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años, 8 meses
Puntos: 12
Respuesta: Listar informacion de un xml

lo intento con el siguiente codigo
Código PHP:
        $xml simplexml_load_string($buffer);
        
$players $xml->server->players;

        
print_r($players);

print
'        
<table width="431" border="0">
  <tr>
    <td width="228"><div align="center">Player Name</div></td>
    <td width="99">Player Score</td>
    <td width="90">Ping</td>
  </tr>'
;

foreach (
$players as $player){
    
    
$name     $player->player->name;
    
$score    $player->player->score;
    
$ping    $player->player->ping;

print
'
<tr>
    <td><div align="center">'
.$name.'</div></td>
    <td><div align="center">'
.$score.'</div></td>
    <td><div align="center">'
.$ping.'</div></td>
  </tr>'
;
}
print
'
</table>
'

pero solo me tira el primer registro, no saca los demas.

esta es la salida del print_r()
Cita:
SimpleXMLElement Object ( [player] => Array ( [0] => SimpleXMLElement Object ( [name] => fat1tyl.pl [score] => 2 [ping] => 217 ) [1] => SimpleXMLElement Object ( [name] => eeeeeeeeeeeeee [score] => 32 [ping] => 75 ) [2] => SimpleXMLElement Object ( [name] => Mr MC Clown [score] => 23 [ping] => 200 ) [3] => SimpleXMLElement Object ( [name] => *{PotW}*^3[U]B3R~ [score] => 49 [ping] => 95 ) [4] => SimpleXMLElement Object ( [name] => *{PotW}*spRonin [score] => 0 [ping] => 45 ) [5] => SimpleXMLElement Object ( [name] => BILL_CANT_RIDE [score] => 26 [ping] => 95 ) [6] => SimpleXMLElement Object ( [name] => chris1369aus [score] => 0 [ping] => 246 ) [7] => SimpleXMLElement Object ( [name] => Danger Prone [score] => 13 [ping] => 51 ) [8] => SimpleXMLElement Object ( [name] => a notion. [score] => 23 [ping] => 41 ) [9] => SimpleXMLElement Object ( [name] => =WD=SS-AUSSIE [score] => 5 [ping] => 201 ) [10] => SimpleXMLElement Object ( [name] => LinfoxJD [score] => 8 [ping] => 248 ) [11] => SimpleXMLElement Object ( [name] => TuFFeNuFF [score] => 15 [ping] => 207 ) [12] => SimpleXMLElement Object ( [name] => player whos wife gives bj when [score] => 8 [ping] => 32 ) [13] => SimpleXMLElement Object ( [name] => Kira [score] => 1 [ping] => 237 ) [14] => SimpleXMLElement Object ( [name] => TOG Mikey [score] => 5 [ping] => 298 ) [15] => SimpleXMLElement Object ( [name] => *{PotW}*NamVet [score] => 0 [ping] => 34 ) [16] => SimpleXMLElement Object ( [name] => {tr}frostbyte [score] => 0 [ping] => 81 ) [17] => SimpleXMLElement Object ( [name] => PowderMonkey [score] => 17 [ping] => 37 ) [18] => SimpleXMLElement Object ( [name] => Unknown Soldier [score] => 4 [ping] => 121 ) [19] => SimpleXMLElement Object ( [name] => PROWLER [score] => 12 [ping] => 32 ) [20] => SimpleXMLElement Object ( [name] => Hammil [score] => 31 [ping] => 48 ) ) )