Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/03/2009, 13:03
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
De acuerdo Respuesta: Leer XML con PHP....

Gracias!!! logre hacerlo...


Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>xml reader</title>
</head>

<body>
<?php
$file
="carrera.xml";
$data =  file_get_contents($file); 
$xml simplexml_load_string($data);

// ejemplo 1
echo $xml->autos->colores->frente;

// ejemplo 2
foreach ($xml->score->jugadores as $jugadores);
//echo $jugadores->jugador[1];
//echo $jugadores->puntaje[1];

?>
<p>Ranking:</p>
<table width="200" border="1">
  <tr>
    <td bgcolor="#CCCCCC"><strong>Jugador</strong></td>
    <td bgcolor="#CCCCCC"><strong>Puntaje</strong></td>
  </tr>
<?php 
$i
=0
$total=count($jugadores->jugador);
do{
?>
  <tr>
    <td><?php echo $jugadores->jugador[$i]; ?></td>
    <td><?php echo $jugadores->puntaje[$i]; ?></td>
  </tr>
<?php $i++; }while($i $total);  ?>
</table>
</body>
</html>
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)