在xml feed上没有返回结果

时间:2012-11-01 19:17:00

标签: php xml

我对使用xml的Php很新。我有一个xml文件,我正在上传Feed,但它没有显示任何结果 这是我的代码

function getFeed($feed_url, $uid) {
$cnt = 0;
set_time_limit(0);
$content = url_get_contents(urldecode($feed_url));
$validXML = simplexml_load_string($content);
 if($validXML===FALSE) {
         echo "false";
    return false;
 } 
 else {
    $x = new SimpleXMLElement($content);

    foreach($x->channel->item as $entry) {
        $category = $entry->category;
        $title = $entry->title;
        $link = $entry->link;
        $pubdate = $entry->pubDate;
        $desc = $entry->description;
        $query = "INSERT INTO `tbl_feed` ( `id` , `uid`, `category` , `title`, `link`, `pubdate`, `description` ) 
                                VALUES ('', '$uid', '$category', '$title' , '$link', '$pubdate', '".mb_convert_encoding($desc,"iso-8859-1","auto")."')";
        echo "<br />";
                    echo $cnt = $cnt+1 ."<br />";

//$dbFun->insertInto($query);
        print($query . "<br><br>");
        //  mysql_query("set CHARACTER SET UTF-8");
        //mysql_query($query); 
    }//foreach ends 
            exit();
}
}

0 个答案:

没有答案