SimpleXMLElement permite parsear XML y manejarlo como objetos php:
$xml = new SimpleXMLElement($xmlstr);
echo $xml->movie[0]->plot;
y escribir estos objetos php como un string xml
echo $xml->asXML();
Referencia:
http://cl2.php.net/manual/en/simplexml.examples.php
El encoding interno es UTF-8. Si se necesita obtener en ISO-8859-1:
// This is what we have today
$sxml = simplexml_load_string($xmlstr);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo utf8_decode($sxml->menu->historico);
$internalEncoding = 'iso-8859-1';
$sxml = simplexml_load_string($xmlstr, $internalEncoding);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo $sxml->menu->historico; // now, no need of utf8_decode
Referencia:
http://bugs.php.net/bug.php?id=32431
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario