Inserir acentos em xml
Olá.
Estou tentando inserir uma mensagem com acentos em um xml, mas dá o erro:
Warning: SimpleXMLElement::asXML() [simplexmlelement.asxml]: output conversion failed due to conv error, bytes 0xE3 0x6F 0x3C 0x2F in /home/siste592/public_html/krtv/publicar0.php
O xml é este:
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<Registros>
</Registros>
</rss>
O PHP este:
<?php
include "conexao.php";
//$img = $_FILES["imagem"]["name"];
$uploaddir = 'IMAGENS/';
$uploadfile = $_FILES['foto']['name'];
//print "<pre>";
if (move_uploaded_file($_FILES['foto']['tmp_name'], $uploaddir . $_FILES['foto']['name'])) {
//print "";
//print_r($_FILES);
} else {
//print "Arquivo não enviado! Aqui esta alguma informação:\n";
//print_r($_FILES);
}
//print "</pre>";
$categoria = $_POST['categoria'];
$nome = $_POST['nome'];
$dianascimento = $_POST['dianascimento'];
$foto = $uploadfile;
$mesnascimento = $_POST['mesnascimento'];
$DataDe = $_POST['data1'];
$DataAte = $_POST['data2'];
//echo "$foto";
//exit();
$mensagem = $_POST['mensagem'];
$mensagem2 = ereg_replace("[^a-zA-Z0-9_]", "", strtr($mensagem, "áàãâéêíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ", "aaaaeeiooouucAAAAEEIOOOUUC_"));
$sql = mysql_query("INSERT INTO noticias (id_categoria, nome, dianascimento, foto, mesnascimento, DataDe, DataAte, mensagem) VALUES ('$categoria', '$nome', '$dianascimento', '$foto', '$mesnascimento', '$DataDe', '$DataAte', '$mensagem')", $conexao) or die ("Erro: ".mysql_error());
$xml = simplexml_load_file("foo.xml"); //This line will load the XML file.
$sxe = new SimpleXMLElement($xml->asXML()); //In this line it create a SimpleXMLElement object with the source of the XML file.
//The following lines will add a new child and others child inside the previous child created.
$canal = $sxe->Registros;
$ticker = $canal->addChild("Registro");
$ticker->addChild("Categoria", $categoria);
$ticker->addChild("Nome", $nome);
$ticker->addChild("DiaNascimento", $dianascimento);
$ticker->addChild("MesNascimento", $mesnascimento);
$ticker->addChild("DataDe", $DataDe);
$ticker->addChild("DataAte", $DataAte);
$ticker->addChild("Mensagem", $mensagem);
$ticker->addChild("Foto", $foto);
//This next line will overwrite the original XML file with new data added
$sxe->asXML("foo.xml");
//file_put_contents ("news_slider/xml/xml01.xml", $sxe, $xml->asXML());
//header("Location: publicar2.php?tipo=$tipo&titulo=$titulo&texto2=$texto2&foto2=$uploadfile2&credito2=$credito2&datainicio=$datainicio&datafim=$datafim&numero=$Numero");
?>
Funciona bem, só não consigo inserir acentos e outros caracteres brasileiros no xml.
Alguém pode me ajudar?
Discussão (4)
Carregando comentários...