<?xml version="1.0" encoding="utf-8"?>
<items count="6"><item id="156" title="联系方式">test不可能吧</item>
</items>
输出是这样子的,我在flash里在调出现乱码。然后把这个xml文件重新用记事本另存为utf-8后才可以,每次生成都这样子,怎么回事呢?
<items count="6"><item id="156" title="联系方式">test不可能吧</item>
</items>
输出是这样子的,我在flash里在调出现乱码。然后把这个xml文件重新用记事本另存为utf-8后才可以,每次生成都这样子,怎么回事呢?
$dom = new DOMDocument("1.0","utf-8");
header("Content-Type: text/plain");
//items
$root = $dom->createElement("items");
$dom->appendChild($root);
//count
$count = $dom->createAttribute("count");
$root->appendChild($count);
$count_value = $dom->createTextNode("6");
$count->appendChild($count_value);
//item
$item = $dom->createElement("item");
$root->appendChild($item);
//$content=iconv("UTF-8","GB2312//IGNORE",$content);
//$content=mb_convert_encoding($content, "utf-8", "GB2312");
$text = $dom->createTextNode($content); $item->appendChild($text);
//id
$id = $dom->createAttribute("id");
$item->appendChild($id);
$idValue = $dom->createTextNode("156");
$id->appendChild($idValue);
//title
$title = $dom->createAttribute("title");
$item->appendChild($title);
$titleValue = $dom->createTextNode("联系方式");
$title->appendChild($titleValue); $content=$dom->saveXML();
$counter_file ='../xml/ContactUs_Address.xml';
$fopen=fopen($counter_file,'wb');
$r=fputs($fopen,$content);
if($r)
{
$this->assign('msg','已经成功生成完毕!');
}
else
{
$this->assign('msg','对不起,内容生成失败!');
}
是这样子的
另外修改
header('Content-Type: text/html; charset=utf-8');