Intentando usar domxml.
| From: | Pablo Braulio | Date: | Tue, 20 May 2008 16:59:30 +0000 |
| Subject: | Intentando usar domxml. | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-62684@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hola a todos.
Estoy intentando usar php con archivos xml por primera vez y me estoy
encontrando algunos problemas.
Lo que trato de hacer leer el contenido de un archivo xml, filtrar el
contenido por tags y luego poder mostrarlo.
He mirado este artículo:
http://www.desarrolloweb.com/articulos/2491.php
y mi problema es este:
Fatal error: Call to undefined function domxml_open_mem() in ...
:-(
Por lo que he podido averiguar es que hay que habilitar la extensión
domxml, pero mi php.ini no la tiene y no se como conseguirla.
Uso php5 y ubuntu.
Os pego el código que he hecho.
- ------------------------
$fichero= "archivo.xml";
$abrir= fopen($fichero, "r");
while($leer= fgets($abrir,1024)){
$contenido .=$leer;
}
fclose($abrir);
$char= array(
"á"=>"a",
"é"=>"e",
"í"=>"i",
"ó"=>"o",
"ú"=>"u",
"ü"=>"u",
"ñ"=>"ny",
"Á"=>"A",
"É"=>"E",
"Í"=>"I",
"Ó"=>"O",
"Ú"=>"U",
"Ü"=>"U",
"Ñ"=>"N");
foreach($char as $key=>$value){
$contenido=
ereg_replace("\"".utf8_decode($key)."\"","\"".$value."\"","".$contenido);
}
$tags= array("hostname","ip","os");
$xml= domxml_open_mem($contenido);
$raiz= $xml->document_element();
$tam= sizeof($tags);
for($i=0;$i<$tam;$i++){
$nodo= $raiz->get_elements_by_tagname($tags[$i]);
$j=0;
foreach($nodo as $etiqueta){
$matriz[$j][$tags[$i]]= $etiqueta->get_content();
$j++;
}
echo $matriz;
}
- ------------------------
Espero que alguno podáis ayudarme con esto.
- --
< ¡¡Nos vemos!! >
----------------------------
\
\
.::!!!!!!!:.
.!!!!!:. .:!!!!!!!!!!!!
~~~~!!!!!!. .:!!!!!!!!!UWWW$$$
:$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P
$$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$#
$$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$*
^$$$B $$$$\ $$$$$$$$$$$$ d$$R"
"*$bd$$$$ '*$$$$$$$$$$$o+#"
"""" """""""
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIMwNxK7lGsMchFswRAktlAJ9YY++U2XVMS0EzLTewRF37YEAhLQCfXer+
JlOpt7U9zpk8pVgriSXFiWA=
=xyig
-----END PGP SIGNATURE-----