Heim >Backend-Entwicklung >PHP-Tutorial > php写XML文件编码异常,求解答
php写XML文件编码错误,求解答
我有一个video的表,数据结构如下:
我利用如下程序读取表中文件,生成XML文件:
<br /> include("conn.php");<br /> include("crop.php");<br /> <br /> $xmlFile = "123.xml";<br /> $dom = new DomDocument('1.0','utf-8');<br /> $dom->formatOutput=true;<br /> $thumbnails = $dom->createElement("thumbnails"); <br /> mysql_select_db('hdm0910283_db', $lnk) or die ('Can\'t use hdm0910283_db : ' . mysql_error());<br /> mysql_query("SET NAMES utf-8"); <br /> $sql="select * from video";<br /> $query=mysql_query($sql);<br /> while ($row = mysql_fetch_array($query)) {<br /> //切割youku截图<br /> $imageurl="../workshow/images/".$row[imgname];<br /> cutphoto("$imageurl","$imageurl",200,113);<br /> $dom -> appendChild($thumbnails); <br /> $thumbnail = $dom->createElement("thumbnail");<br /> $thumbnail->setAttribute('filename', $row[imgname]);<br /> $thumbnail->setAttribute('label', $row[title]);<br /> $thumbnail->setAttribute('url', $row[url]);<br /> $thumbnails -> appendChild($thumbnail);<br /> }<br /> $dom->save($xmlFile);<br />