Page 1 of 1

creat a xml file

Posted: Tue Jun 21, 2011 1:22 pm
by srdva59
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

Code: Select all

  	$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
:)

Re: creat a xml file

Posted: Wed Jun 22, 2011 1:10 am
by McInfo