It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

creat a xml file

Moderator: Malcolm

creat a xml file

Postby jason213123 on Tue Jun 21, 2011 6:27 pm

hi,
i have this code that can creat a xml but my problem is with the encoding
i using words like : olá, ção, á
and that characters don´t appear correcly and when i try read the xml
a error is displayed about that character


$dom = new DOMDocument("1.0", "utf-8");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$root = $dom->createElement("hoteis");

while ($row = mysql_fetch_assoc($result)) {

#nó filho (contato)
$contato = $dom->createElement( "m" . $row['id'] );

#setanto nomes e atributos dos elementos xml (nós)
$nome = $dom->createElement("nome", $row['nome'] );

$dt1 = $dom->createElement("data1", $row['data'] );
$dt2 = $dom->createElement("data2", $row['data2'] );
$v1 = $dom->createElement("valor1", $row['valor'] );
$v2 = $dom->createElement("valor2", $row['valor2'] );

#adiciona os nós (informacaoes do contato) em contato
$contato->appendChild($nome);
$contato->appendChild($dt1);
$contato->appendChild($dt2);
$contato->appendChild($v1);
$contato->appendChild($v2);


#adiciona o nó contato em (root) agenda
$root->appendChild($contato);
$dom->appendChild($root);

what i need change to fix that problem?
thanks for your help
:)
jason213123
 
Posts: 36
Joined: Sat Mar 01, 2008 11:16 am

Re: creat a xml file

Postby rajmv on Sun Jul 17, 2011 5:26 pm

try

$dom = new DOMDocument("1.0", "utf-16");

or

$dom = new DOMDocument("1.0", "ISO-10646");
rajmv
100+ Club
 
Posts: 103
Joined: Thu Jul 14, 2011 7:22 am


Who is online

Users browsing this forum: No registered users and 1 guest