0

http://seosailor.com/beta2/articles/showrssこの URL でエラーが発生します Chrome のドキュメントの最後に余分なコンテンツが表示されます

私のコードはこれです

function showrss() {
    header("Content-Type: application/xml; charset=ISO-8859-1");
     $query_items = "select * from articles";   
    $result_items  = mysql_query ($query_items) or die("Some error: ".mysql_error());                             
    $xml = '<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel>';
    while($row = mysql_fetch_array($result_items))
        { 
            //$des = mysql_real_escape_string($row['a_description']);
        //  $a_des = str_replace(']]>', ']]&gt;',$row['a_description']);
            //$a_des = strip_tags($row['a_description']);
        //  $a_des = preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags($row['a_description']));
            $a_des = htmlspecialchars($row['a_description']);
        $xml .= '<item>
         <title>'.$row["a_title"].'</title>
         <link>'.$row["a_url"].'</link>
         <description>'.$a_des.'</description></item>';
        }   $xml .= '</channel>';
             $xml .= '</rss></xml>';
            echo $xml;}
4

1 に答える 1

1

これ</xml>は、末尾に余分な終了タグがあるためです (開始<xml>タグはありません)。

于 2013-09-12T14:21:08.800 に答える