Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/08/2011, 07:06
auri501
 
Fecha de Ingreso: octubre-2007
Mensajes: 130
Antigüedad: 16 años, 7 meses
Puntos: 2
Respuesta: leer xml con php

Dejo la solución para el que le pueda interesar:
Cita:
<?php
$cdCatalogXMLReader = new CDCatalogXMLReader();
$cdCatalogXMLReader->showCatalogAsTable($url);

class CDCatalogXMLReader {
public function showCatalogAsTable($xmlPath) {
// Loads XML.
$doc = new DOMDocument();
$doc->load($xmlPath);
echo $doc->saveXML();
// Reading tag's value.


echo "<h1>Datos cliente</h1>";

// Reading all elements with tag name="cd".
$cds = $doc->getElementsByTagName("entry");

echo '<table border="1">';

echo '<tr>';
foreach ($cds as $cd) {
// Reading attributes.
echo '<td>' . $cd->getElementsByTagName("string")->item(0)->nodeValue . '</td>';
}
echo '</tr>';
echo '<tr>';
foreach ($cds as $cd) {
// Reading attributes.
echo '<td>' . $cd->getElementsByTagName("string")->item(1)->nodeValue . '</td>';
}
echo '</tr>';
echo '</table>';
}
}
?>
Un saludo y espero que le sirva a alguien!!