Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/03/2010, 06:03
druha
 
Fecha de Ingreso: marzo-2009
Mensajes: 16
Antigüedad: 15 años, 2 meses
Puntos: 0
Respuesta: Problema simplexml con fichero KML

Gracias Eleazan, parece que ya di con el fallo. Con la etiqueta kml obtengo esto:

Código HTML:
<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></HEAD><BODY><PRE>SimpleXMLElement Object
(
    [Document] =&gt; SimpleXMLElement Object
        (
            [Placemark] =&gt; Array
                (
                    [0] =&gt; SimpleXMLElement Object
                        (
                            [@attributes] =&gt; Array
                                (
                                    [targetID] =&gt; 3
                                )

                            [name] =&gt; 3
                            [Point] =&gt; SimpleXMLElement Object
                                (
                                    [coordinates] =&gt; -15.520963805572499,28.041931931319802
                                )

                        )
...
</PRE><BR>
<B>Notice</B>:  Trying to get property of non-object in <B>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\prueba.php</B> on line <B>11</B><BR>
</BODY></HTML> 
Sin la etiqueta kml:

Código HTML:
<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></HEAD><BODY><PRE>SimpleXMLElement Object
(
    [Placemark] =&gt; Array
        (
            [0] =&gt; SimpleXMLElement Object
                (
                    [@attributes] =&gt; Array
                        (
                            [targetID] =&gt; 3
                        )

                    [name] =&gt; 3
                    [Point] =&gt; SimpleXMLElement Object
                        (
                            [coordinates] =&gt; -15.520963805572499,28.041931931319802
                        )

                )
...
)
</PRE>3</BODY></HTML> 
O sea, que la forma correcta sería:

Código PHP:
echo $kml->Document[0]->Placemark[0]->name
Sinceramente no entiendo muy bien por qué se construyen de forma diferente (el nodo document ni siquiera aparece en la segunda versión), pero bueno, supongo que habrá que sacarlo a base de prueba y error

Pues eso, gracias por la ayuda