- 论坛徽章:
- 0
|
原帖由 legend9 于 2006-10-11 06:46 发表
应该声明一下xml文件的编码
<?xml version="1.0" encoding="utf-8" ?>
另外mb_detect_encoding并不是很准确。
加了声明encoding="utf-8"后可以打开,中文可以正确显示,但是有些显示的出来,有些显示不出来.
代码如下
- foreach($data as $row)
- {
- $content1="<node>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="sn">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_sn'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="oldno">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_old_No'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="name">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_name'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="type">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_type'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="note">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_notes_i'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="no1">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_No_1'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="no2">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_No_2'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="no3">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_No_3'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1='<parts property="unit">';
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1=$row['parts_unit'];
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</parts>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- $content1="</node>\n";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
- }
- $content1="</data>";
- $content .=iconv(mb_detect_encoding($content1), "UTF-8",$content1);
复制代码
结果如下
- <?xml version="1.0" encoding="utf-8" ?>
- - <data>
- - <node>
- <parts property="sn">458</parts>
- <parts property="oldno">843003</parts>
- <parts property="name" />
- <parts property="type" />
- <parts property="note" />
- <parts property="no1">8401013-**</parts>
- <parts property="no2">1</parts>
- <parts property="no3">3044</parts>
- <parts property="unit">件</parts>
- </node>
- - <node>
- <parts property="sn">459</parts>
- <parts property="oldno">843007</parts>
- <parts property="name">发动机罩锁总成</parts>
- <parts property="type" />
- <parts property="note" />
- <parts property="no1">8402100-**</parts>
- <parts property="no2">1</parts>
- <parts property="no3">3044</parts>
- <parts property="unit" />
- </node>
- - <node>
- <parts property="sn">461</parts>
- <parts property="oldno">842002</parts>
- <parts property="name" />
- <parts property="type">B=400</parts>
- <parts property="note" />
- <parts property="no1">8403012-**</parts>
- <parts property="no2">1</parts>
- <parts property="no3">3044</parts>
- <parts property="unit">件</parts>
- </node>
复制代码
[ 本帖最后由 LiveHappy 于 2006-10-11 10:13 编辑 ] |
|