Foros del Web » Programando para Internet » PHP »

Como leo atributos de XML con DOM ?

Estas en el tema de Como leo atributos de XML con DOM ? en el foro de PHP en Foros del Web. Amigos : quiero leer atributos presentes en un XML y no logro hacerlo Les paso el documento y luego el programita...... gracias! <?xml version="1.0" encoding="ISO-8859-1"?> ...
  #1 (permalink)  
Antiguo 29/06/2009, 15:43
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Exclamación

Amigos: quiero leer atributos presentes en un XML y no logro hacerlo

Les paso el documento y luego el programita...... gracias!

<?xml version="1.0" encoding="ISO-8859-1"?>
<feed>
<entry>
<title>Post Nro 1</title>
<content>
La vida del tipo mas vago
</content>
<id></id>
<published></published>
<updated></updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/xxx/2008/kind#settings'/><!-- no sirve para nada -->
</entry>
<entry>
<title>Post Segundo</title>
<content>
Que ganas de descansar!
</content>
<id></id>
<published></published>
<updated></updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/xxx/2008/kind#settings'/><!-- no sirve para nada -->
</entry>
<entry>
<id>tag:xxx.com,1999:blog-7024066239988926088.post-766833419234083812</id>
<published>2009-05-08T21:07:00.000-03:00</published>
<updated>2009-05-08T21:07:37.810-03:00</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/xxx/2008/kind#comment'/>
<title type='text'>Que super ni 8/4! es una ....</title>
<content type='html'>Aca comento sobre el particular...</content>
<link rel='edit' type='application/atom+xml' href='http://www.xxx.com/feeds/7024066239988926088/3092247673669125375/comments/default/766833419234083812'/>
<link rel='self' type='application/atom+xml' href='http://www.xxx.com/feeds/7024066239988926088/3092247673669125375/comments/default/766833419234083812'/>
<link rel='alternate' type='text/html' href='http://tecnologia2web.mastecno.com/2007/09/fotos-de-aviones.html?showComment=1241827620000#c7668334192 34083812' title=''/>
<author>
<name>Anonymous</name>
<email>[email protected]</email>
</author>
<thr:in-reply-to href='http://tecnologia2web.mastecno.com/2007/09/fotos-de-aviones.html' ref='tag:xxx.com,1999:blog-7024066239988926088.post-3092247673669125375' source='http://www.xxx.com/feeds/7024066239988926088/posts/default/3092247673669125375' type='text/html'/>
</entry>
</feed>


Código PHP:
// Parseo 

  
$objDOM = new DOMDocument();
  
$objDOM->load("mt2.xml"); //make sure path is correct

  
$entry $objDOM->getElementsByTagName("entry");

  foreach( 
$entry as $value )
  {
    
$titles $value->getElementsByTagName("title");
    
$title  $titles->item(0)->nodeValue;


    
$contents $value->getElementsByTagName("content");
    
$content  $contents->item(0)->nodeValue;

    echo 
"<h2>$title</h2><br>$content<p/>";    
    
    
    
$urls $value->getElementsByTagName("thr:in-reply-to");    /////// que pongo aca????
    
echo $urls->get_attribute('href'); 

  }


?> 
En principio quiero parsear "thr:in-reply-to" y obtener el HREF
gracias!

NADIE me ayda?

Necesito ayuda........ amigos

Ok,...nadie me ayuda.... bueno..... creo que voy a resolverlo con XML SIMPLE y quiero recomendar este tutorial
__________________
Salu2!

Última edición por GatorV; 30/06/2009 a las 10:53
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:26.