Ver Mensaje Individual
  #7 (permalink)  
Antiguo 22/10/2012, 10:40
ealabau
 
Fecha de Ingreso: octubre-2012
Mensajes: 1
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Problemas al leer XML con SIMPLEXML

Hola, tengo un xml de esta manera : <?xml version="1.0" encoding="ISO-8859-1"?>
<tns:Tomo1 xmlns:tns="http://www.example.org/Tomo1Bopi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/Tomo1Bopi https://sede.oepm.gob.es/bopiweb/xsd/tomo1/Tomo1_v1.42.xsd">
<tns:Marcas>
<tns:SolicitudesMarcas>
<tns:SolicitudMarca>
<tns:PublicacionId>881716</tns:PublicacionId>
<tns:Modalidad>M</tns:Modalidad>
<tns:p21_NumSolicitud>3032565</tns:p21_NumSolicitud>
<tns:Bis> </tns:Bis>
<tns:DigitoControl>X</tns:DigitoControl>
<tns:ApellidosTitular>ENTE PUBLICO RADIO - TELEVISION DE CASTILLA - LA MANCHA</tns:ApellidosTitular>
<tns:FechaDepositoRegular>29/05/2012</tns:FechaDepositoRegular>
<tns:TipoSigno>D</tns:TipoSigno>
<tns:Domicilio>RIO ALBERCHE SN</tns:Domicilio>
<tns:CodigoPostal>45007</tns:CodigoPostal>
<tns:PaisDeResidencia>ES</tns:PaisDeResidencia>
<tns:Localidad>TOLEDO</tns:Localidad>
<tns:Provincia>TOLEDO</tns:Provincia>
<tns:Denominacion>DESCUBRIENDO NUESTRA TIERRA</tns:Denominacion>
<tns:ProductosServiciosActividades>38-EMISION Y DIFUSION DE PROGRAMAS DE TELEVISION Y RADIO; SERVICIOS DE RADIODIFUSION; TELEVISION POR CABLE; TRANSMISION VA SATELITE; COMUNICACIONES; SERVICIOS DE TELECOMUNICACIONES A TRAVES DE REDES MUNDIALES DE INFORMATICA. </tns:ProductosServiciosActividades>
<tns:ProductosServiciosActividades>41-PRODUCCION Y MONTAJE DE PROGRAMAS DE TELEVISION Y RADIOFONICOS; ORGANIZACION DE CONCURSOS, DIVERSIONES TELEVISIVAS Y RADIOFONICAS, ENTRETENIMIENTOS TELEVISADOS; ORGANIZACION, PRODUCCION Y REPRESENTACION DE ESPECTACULOS; PRODUCCION DE PELICULAS (FILMS). EDUCACION; FORMACION PRESENCIAL Y A DISTANCIA; ESPARCIMIENTO; ACTIVIDADES DEPORTIVAS Y CULTURALES; ORGANIZACION DE CONFERENCIAS Y SEMINARIOS. </tns:ProductosServiciosActividades>
<tns:ApellidosRepresentante>Lahidalga de Careaga</tns:ApellidosRepresentante>
<tns:NombreRepresentante>José Luis</tns:NombreRepresentante>
<tns:DomicilioRepresentante>C/ Arturo Soria,243 Dpl. Esc.4-1º Izq.</tns:DomicilioRepresentante>
<tns:CPRepresentante>28033</tns:CPRepresentante>
<tns:PaisRepresentante>ES</tns:PaisRepresentante>
<tns:LocalidadRepresentante>Madrid</tns:LocalidadRepresentante>
<tns:ProvinciaRepresentante>MADRID</tns:ProvinciaRepresentante>
<tns:imagen>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBA=</tns:imagen>
</tns:SolicitudMarca>


</tns:SolicitudesMarcas>
</tns:Marcas>
</tns:Tomo1>


Y cuando lo recorro asi me sale en blanco los valores de los nodos que quiero ver. Alguna sugerencia?

$xml="tomo1.xml";
$sxe = simplexml_load_file($xml);
$ns = $sxe->getNamespaces(true);
$sxe->registerXPathNamespace('t', $ns['tns']);
//$sxe->registerXPathNamespace('t', $ns['tfd']);

foreach ($sxe->xpath('//t:Tomo1//t:Marcas//t:SolicitudesMarcas//t:SolicitudMarca') as $tfd) {
echo $tfd['PublicacionId']."<br />";
echo $tfd['Modalidad']."<br />";

}