PHP生成的XML文档中的多种编码类型

时间:2013-08-23 23:46:18

标签: php xml encoding utf-8 rss

我正在使用PHP生成RSS源,其中包含位于服务器上存储的文件中的描述文本。问题是,文件的编码方式不同,有些是UTF-8,us-ascii等。统一每种描述的编码有什么好方法?

我已经尝试了this,但我仍然在XML文件中收到错误。

这是the error 我的代码

<channel>
<?php
    mysql_connect(xxx);
    mysql_select_db(xxx);
    $result = mysql_query("SELECT * FROM articles");
    while ($row = mysql_fetch_array($result)) {
        echo "<item>";
        echo "<description>";
        echo file_get_contents($row['location']); 
        echo "</description>";
        #The location to the file containing the article is in the DB, clearly.
        echo "<title>";
        echo $row['title'];
        echo "</title>";
        echo "<link>";
        echo "[link to entry goes here...]";
        echo "</link>";
        #Echo some more RSS tags that I don't need to specify in this example. 
        echo "</item>";
?>
</channel>

0 个答案:

没有答案