<?xml version="1.0" encoding="utf-8"?>
<items count="6"><item id="156" title="联系方式">test不可能吧</item>
</items>
输出是这样子的,我在flash里在调出现乱码。然后把这个xml文件重新用记事本另存为utf-8后才可以,每次生成都这样子,怎么回事呢?

解决方案 »

  1.   

    生成xml文件的时候设置好编码utf-8,把代码贴出来看看
      

  2.   

    $content=$model->where("title='联系我们'")->getField('content');
    $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','对不起,内容生成失败!');
    }
    是这样子的
      

  3.   

    你生成xml的这个文件编码设置成utf-8
    另外修改
    header('Content-Type: text/html; charset=utf-8');
      

  4.   

    http://topic.csdn.net/u/20120404/12/65a66f87-efb1-4404-82e5-302664abdde6.html  已在这里解决!