How to convert characters within XML?

Asked

Viewed 136 times

-1

I have a code that is giving me problems because it is generating errors in the execution. I need the XML convert or replace characters but do not know how to do it at runtime. I am trying to do so but unsuccessfully.

<?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 my generation XML, this:

$xml.= preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $xml);
  • Dear Are you creating the XML at hand? If you look at these articles: article 1 Article 2 , and take a look if it will help you build the document.

1 answer

1


Just use utf8_decode

echo utf8_decode( 'dormitórios' );

Output: dorms

Browser other questions tagged

You are not signed in. Login or sign up in order to post.