elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Abrir un XML
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Abrir un XML  (Leído 4,219 veces)
Zieg Uchiha

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Abrir un XML
« en: 2 Abril 2009, 21:33 pm »

HOla e buscado en muchos foros y no encontrado respuesta.

quiero abrir un XML y el simplexml_load_file no me va.

este es el archivo con el que estoy haciendo pruebas

Código
  1.  
  2. <?xml version='1.1' standalone='yes'?>
  3. <movies>
  4. <movie>
  5.  <title>PHP: Behind the Parser</title>
  6.  <characters>
  7.   <character>
  8.    <name>Ms. Coder</name>
  9.    <actor>Onlivia Actora</actor>
  10.   </character>
  11.   <character>
  12.    <name>Mr. Coder</name>
  13.    <actor>El Act&#38;#211;r</actor>
  14.   </character>
  15.  </characters>
  16.  <plot>
  17.   So, this language. It's like, a programming language. Or is it a
  18.   scripting language? All is revealed in this thrilling horror spoof
  19.   of a documentary.
  20.  </plot>
  21.  <rating type="thumbs">7</rating>
  22.  <rating type="stars">5</rating>
  23. </movie>
  24. </movies>
  25.  

y pruebo con este script para ver que pasa

Código
  1. <?php
  2. // El fichero test.xml contiene un documento XML con el elemento raiz
  3. // y almenos un elemento /[root]/title.
  4.  
  5. if (file_exists('ejemplo.xml')) {
  6.    $xml = simplexml_load_file('ejemplo.xml');
  7.  
  8.    var_dump($xml);
  9. } else {
  10.    exit('Error al abrir test.xml.');
  11. }
  12. ?>
  13.  

al ejecutar esto me da estos errores.

Citar

Warning: simplexml_load_file() [function.simplexml-load-file]: ejemplo.xml:2: parser error : XML declaration allowed only at the start of the document in C:\AppServ\www\experimentos2.php on line 6

Warning: simplexml_load_file() [function.simplexml-load-file]: <?xml version='1.1' standalone='yes'?> in C:\AppServ\www\experimentos2.php on line 6

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\AppServ\www\experimentos2.php on line 6
bool(false)

espero puedan ayudarme.

Thx

saludos.


En línea

HardieVon

Desconectado Desconectado

Mensajes: 181


Programming HardCore


Ver Perfil WWW
Re: Abrir un XML
« Respuesta #1 en: 2 Abril 2009, 21:55 pm »

esta mal la cabecera.

ponle esto.
Código
  1. <?xml version="1.0"?>

en vez de lo que tiene,


En línea

Zieg Uchiha

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: Abrir un XML
« Respuesta #2 en: 2 Abril 2009, 22:02 pm »

No pasa nada :( es lo mismo.
En línea

HardieVon

Desconectado Desconectado

Mensajes: 181


Programming HardCore


Ver Perfil WWW
Re: Abrir un XML
« Respuesta #3 en: 2 Abril 2009, 22:17 pm »

como crees si yo ya lo probe
Código
  1. <?xml version="1.0"?>
  2.  
  3. <movies>
  4.  
  5. <movie>
  6.  
  7.  <title>PHP: Behind the Parser</title>
  8.  
  9.  <characters>
  10.  
  11.   <character>
  12.  
  13.    <name>Ms. Coder</name>
  14.  
  15.    <actor>Onlivia Actora</actor>
  16.  
  17.   </character>
  18.  
  19.   <character>
  20.  
  21.    <name>Mr. Coder</name>
  22.  
  23.    <actor>El Act&#38;#38;#211;r</actor>
  24.  
  25.   </character>
  26.  
  27.  </characters>
  28.  
  29.  <plot>
  30.  
  31.   So, this language. It's like, a programming language. Or is it a
  32.  
  33.   scripting language? All is revealed in this thrilling horror spoof
  34.  
  35.   of a documentary.
  36.  
  37.  </plot>
  38.  
  39.  <rating type="thumbs">7</rating>
  40.  
  41.  <rating type="stars">5</rating>
  42.  
  43. </movie>
  44.  
  45. </movies>
En línea

Syphroot

Desconectado Desconectado

Mensajes: 268


All You Need To Do Is Follow The Worms


Ver Perfil WWW
Re: Abrir un XML
« Respuesta #4 en: 3 Abril 2009, 05:11 am »

Código:
<?xml version='1.1' standalone='yes'?>
prueba a poner los valores entre comillas dobles "1.0" y "yes"
En línea

Zieg Uchiha

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: Abrir un XML
« Respuesta #5 en: 3 Abril 2009, 16:53 pm »

despues de muchos intentos me funciono, es raro por que a veces me tira error diciendome que no puede abrirlo o que no lo reconoce, pero en fin.

Gracias.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Abrir odt en Ms
Software
huerto123 2 1,579 Último mensaje 12 Julio 2020, 09:26 am
por huerto123
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines