How to convert characters within XML?

-1

I have a code that is giving me problems because it is generating errors in execution. I need XML to convert or replace characters but I do not know how to do this at runtime. I'm trying to do this but to no avail.

<?php

// Receberá todos os dados do XML
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';

// Raiz do documento XML
$xml .= '<Imobiliaria>';

// Loop dos valores
for ( $i = 0; $i<count($res)-1; $i++ ) {

    $xml .= '<Imovel>';

    $xml.="<DESCRICAO>".$res[$i]["Descricao"]."</DESCRICAO>";

    $xml.= preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $xml);

    $xml.= '</Imovel>';

$xml .= '<Imobiliaria>';

?>

I need to know exactly where, how and variables needed in this code to replace or convert characters and eliminate errors in the generation of my XML , this:

$xml.= preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $xml);
    
asked by anonymous 06.09.2014 / 16:34

1 answer

1

Just use utf8_decode

echo utf8_decode( 'dormitórios' );

Output: dorms

    
07.09.2014 / 00:48