Ver Mensaje Individual
  #13 (permalink)  
Antiguo 24/05/2012, 11:13
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: ¿Cómo leer XML directamente con PHP?

Código PHP:
Ver original
  1. <?php
  2. $sXML = <<<XML
  3. <wfs:FeatureCollection xmlns:Mobile="http://www.ejemplo.com/MapServer/WFSServer" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="www.ejemplo.com/MapServer/WFSServerhttp://www.ejemplo.com/MapServer/WFSServer?request=DescribeFeatureType%26version=1.1.0%26typename=TestLayer http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
  4.     <gml:boundedBy>
  5.         <gml:Envelope srsName="urn:ogc:def:crs:EPSG:6.9:3857">
  6.             <gml:lowerCorner>-7493200.6969000008 1138783.0582999997</gml:lowerCorner>
  7.             <gml:upperCorner>-7416878.3242000006 1184981.5566999987</gml:upperCorner>
  8.         </gml:Envelope>
  9.     </gml:boundedBy>
  10.     <gml:featureMember>
  11.         <Mobile:Eventos gml:id="1">
  12.             <Mobile:OBJECTID>4</Mobile:OBJECTID>
  13.             <Mobile:Tutulo_del_Evento>Evento de prueba</Mobile:Tutulo_del_Evento>
  14.             <Mobile:Direccion>Dirección de prueba</Mobile:Direccion>
  15.             <Mobile:Descripcion>Descripción de prueba</Mobile:Descripcion>
  16.             <Mobile:Fecha>2011-03-18T21:55:34</Mobile:Fecha>
  17.             <Mobile:Hora>11:00 a.m.</Mobile:Hora>
  18.             <Mobile:Estatus>0</Mobile:Estatus>
  19.             <Mobile:Tipo_de_Evento>3</Mobile:Tipo_de_Evento>
  20.             <Mobile:MUNICIPIO>1</Mobile:MUNICIPIO>
  21.             <Mobile:PARROQUIA>1</Mobile:PARROQUIA>
  22.             <Mobile:SHAPE>
  23.                 <gml:Point>
  24.                     <gml:pos>-3447172.5109000001 2174911.2608000003</gml:pos>
  25.                 </gml:Point>
  26.             </Mobile:SHAPE>
  27.         </Mobile:Eventos>
  28.     </gml:featureMember>
  29. </wfs:FeatureCollection>
  30. XML;
  31.  
  32. $oXML = simplexml_load_string($sXML);
  33. if (!$oXML) {
  34.     echo "Failed loading XML\n";
  35.     foreach(libxml_get_errors() as $error) {
  36.         echo "\t", $error->message . "<br />";
  37.     }
  38. }

Eso me indica esto:
Cita:
Failed loading XML Input is not proper UTF-8, indicate encoding ! Bytes: 0xF3 0x6E 0x20 0x64
Saludos.

Última edición por GatorV; 24/05/2012 a las 11:21