Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/08/2010, 08:56
Serenity
 
Fecha de Ingreso: marzo-2002
Mensajes: 299
Antigüedad: 22 años, 2 meses
Puntos: 1
Obtener nodos internos de XML

Hola!!, estoy usando la extensión de php5, y no había tenido problema porque tenía que acceder a información de nodos primarios, como en la siguiente estructura de XML:


<?xml version="1.0" ?>
<library>
<book>
<title>Fahrenheit 451</title>
<author>R. Bradbury</author>
<publisher>Del Rey</publisher>
</book>
<book>
<title>The Silmarillion</title>
<author>J.R.R. Tolkien</author>
<publisher>G. Allen & Unwin</publisher>
</book>
<book>
<title>1984</title>
<author>G. Orwell</author>
<publisher>Signet</publisher>
</book>
</library>

para obtener la información de esta estructura lo hago de la siguiente forma:

$xml_llamada=file_get_contents("http://xml.library.com/xml/enginexml-library.asmx/getQuoteBooks;

$xml = new SimpleXMLElement($xml_llamada);

foreach($xml->library->book as $item){
echo "Libro: ".$item->title."<br>";
echo "Autor: ".$item->author."<br>";
echo "Editorial: ".$item->publisher."<br>";
}

pero ahora tengo que acceder a nodos internos, como en la siguiente estructura:


<library>
<book>
<title>Fahrenheit 451</title>
<author>R. Bradbury</author>
<publisher>Del Rey</publisher>
<summary>
<chapter>
<number>I</number>
<description>Aquí el resumen del capitulo I</description>
</chapter>
<chapter>
<number>II</number>
<description>Aquí el resumen del capitulo II</description>
</chapter>
<chapter>
<number>III</number>
<description>Aquí el resumen del capitulo III</description>
</chapter>
</summary>
</book>
<book>
<title>The Silmarillion</title>
<author>J.R.R. Tolkien</author>
<publisher>G. Allen & Unwin</publisher>
<summary>
<chapter>
<number>I</number>
<description>Aquí el resumen del capitulo I</description>
</chapter>
<chapter>
<number>II</number>
<description>Aquí el resumen del capitulo II</description>
</chapter>
<chapter>
<number>III</number>
<description>Aquí el resumen del capitulo III</description>
</chapter>
</summary>
</book>
<book>
<title>1984</title>
<author>G. Orwell</author>
<publisher>Signet</publisher>
<summary>
<chapter>
<number>I</number>
<description>Aquí el resumen del capitulo I</description>
</chapter>
<chapter>
<number>II</number>
<description>Aquí el resumen del capitulo II</description>
</chapter>
<chapter>
<number>III</number>
<description>Aquí el resumen del capitulo III</description>
</chapter>
</summary>
</book>
</library>

Pero mi problema es que no sé como llegar a la información de los nodos correspondiente a summary -> chapter -> number

Desde ya gracias por su atención y ayuda.