Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/12/2009, 04:09
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 1 mes
Puntos: 20
Respuesta: Ayuda cómo leer un xml con simpleXML

Cita:
Iniciado por jackson666 Ver Mensaje
Todo es cosa de paciencia y usar la herramienta correcta

Código PHP:
<?php
$dom 
= new DOMDocument();

$dom->load('algo.xml');

$root=$dom->getElementsByTagName('ROOT')->item(0);

#con esto ves el 1er atributo de todos
echo $root->getAttribute('GMTNow');

echo 
"<br />";

$tagE $dom->getElementsByTagName('E');
$tagG $dom->getElementsByTagName('G');
$tagR $dom->getElementsByTagName('R');

foreach(
$tagE as $e){

            echo 
$e->getAttribute('DBID')."<br />";
            echo 
$e->getAttribute('N')."<br />";  
            echo 
$e->getAttribute('D')."<br />";
            echo 
$e->getAttribute('StdEventDate')."<br />";
            echo 
$e->getAttribute('StdEventDate_UTC')."<br />";
            echo 
$e->getAttribute('SID')."<br />";
            echo 
$e->getAttribute('RID')."<br />";
            echo 
$e->getAttribute('LID')."<br />";
            
    foreach(
$tagG as $g){
        
            echo 
$g->getAttribute('DBID')."<br />";
            echo 
$g->getAttribute('EID')."<br />";
            echo 
$g->getAttribute('N')."<br />";  
            echo 
$g->getAttribute('GT')."<br />";
        
        foreach(
$tagR as $r){
            echo 
$r->getAttribute('DBID')."<br />";
            echo 
$r->getAttribute('N')."<br />";
            echo 
$r->getAttribute('O')."<br />";    
        }
    }
}

?>
Muchísimas gracias jackson666! ahora me queda muchísimo más claro como acceder a las posiciones que quiera!

Por cierto, sabes porque aparece este mensaje al analizar los datos desde una URL HTTPS

Warning: DOMDocument::load() [function.DOMDocument-load]: SSL: fatal protocol error in C:\AppServ\www\00-laboratorio_test\secciones\xml\ejemplo2.php on line 6

La linea 6 coincide con el load a una pagina HTTPS

Y al final del archivo aparece que ha superado el máximo de ejecución. Lo tenía puesto a 30 seg. Lo he ampliado a 120 seg. pero parece que no es suficiente... es normal ampliarlo tanto?¿

Fatal error: Maximum execution time of 120 seconds exceeded in C:\AppServ\www\00-laboratorio_test\secciones\xml\ejemplo2.php on line 37

Los valores de mi configuracion PHP.INI

max_execution_time = 120 ; Maximum execution timeof each script, in seconds
max_input_time = 120 ; Maximum amount of time each script may spend parsing request data
memory_limit = 35M ; Maximum amount of memory a script may consume (8MB)

Muchas gracias de antemano!