jason213123 Posted June 21, 2011 Share Posted June 21, 2011 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 Link to comment https://forums.phpfreaks.com/topic/240021-creat-a-xml-file/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.