Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2013, 05:45
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
Duda en poder mostrar datos de un xml

Estoy tratando de lograr poder hacer esto posible quiero mostrar unos datos de un archivo xml mostralo en php pero estoy teniendo eror aqui dejo los archivos y lo que ya tengo funcionando


archivo.xml

Código XML:
Ver original
  1. <fslb>
  2.     <cache-listeners>
  3.         <listener>
  4.             <connected-client enabled="1" ip-address="192.168.1.81" time-connected="1:16:55"/>
  5.         </listener>
  6.     </cache-listeners>
  7.     <currently-active-cache>
  8.         <provider>
  9.             <cache-element sid="0167" source="External" />
  10.             <cache-element sid="0137" source="External" />
  11.             <cache-element sid="0230" source="Internal" />
  12.             <cache-element sid="0159" source="External" />
  13.         </provider>
  14.     </currently-active-cache>
  15. </fslb>

index.php

Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Servicio Up</title>
  5. </head>
  6.  
  7. <body>
  8. <table width="200" border="1">
  9.   <tr>
  10.     <td align="center">Canales Activos</td>
  11.   </tr>
  12. <?php  
  13.  
  14. $ip = "192.168.1.1";
  15. $port = "5050";
  16. $user = "user";
  17. $pass = "pass";
  18. $i = 0;
  19.  
  20. $xml = simplexml_load_file("http://".$user.":".$pass."@".$ip.":".$port."/archivo.xml");
  21.  
  22. $currently = "currently-active-cache";
  23. $cache = "cache-element";
  24.  
  25. foreach($xml->$currently->provider->$cache as $sids) {
  26.  
  27.                     $xmlsid = "";
  28.                     $xmlsid = (string)$xml->$currently->provider->$cache->attributes()->sid;
  29.  
  30.                     $info[$xmlsid."-sid"] = (string)$xml->$currently->provider->$cache->attributes()->sid;
  31.   echo "<tr>";
  32.   echo "<td>".$xmlsid."</td>";
  33.   echo "</tr>";
  34.                     $i++;
  35.                 }
  36.  
  37.  ?>
  38. </table>
  39. </body>
  40. </html>

me muestra todos el listado pero con un solo sid

ejemplo

0167
0167
0167
0167

en vez que lo haga asi como el listado

0137
0159
0167
0230

que estoy haciendo mal