我需要从 XML 中获取所有节点。在我尝试使用下面的 PHP 编码之后。这是工作。但我无法<description>
从 xml 抓取和图像。
这是来自其他网站的 XML(UTF-8 泰语) http://www.dailynews.co.th/rss/rss.xml
这是我的 PHP 代码:
$Rsssurl_SQL="SELECT * from rss_feed_url";
$Rsssurl_RESULT=mysql_db_query($dbname,$Rsssurl_SQL);
while ($Rsssurl_ROW=mysql_fetch_array($Rsssurl_RESULT)) {
$request_url = $Rsssurl_ROW[1];
$xml = simplexml_load_file($request_url) or die("");
foreach($xml->channel->item as $item){
$title = $item->title;
$content = $item->description;
$date = $item->pubDate;
$link = $item->link;
/* I use ereg_replace to replace special characters */
$content=ereg_replace("<","<",$content);
$content=ereg_replace(">",">",$content);
$content=ereg_replace("&","&",$content);
$content=ereg_replace(""","\"",$content);
$content=ereg_replace("'","\'",$content);
$title=ereg_replace("<","<",$title);
$title=ereg_replace(">",">",$title);
$title=ereg_replace("&","&",$title);
$title=ereg_replace(""","\"",$title);
$title=ereg_replace("'","\'",$title);
$title=ereg_replace("\'","",$title);
$title=ereg_replace("<","", $title);
$title=ereg_replace(">","", $title);
$title=ereg_replace("&","", $title);
$title=ereg_replace("\"","", $title);
}
}
我可以抓取<title>
,<link>
和<pubDate>
insert all 到 mySQL。但只有<description>
我不能全部抓住(图像和长文本)。
我尝试从许多帮助中搜索并从 W3C 学校阅读。我找不到确切的答案。
请,帮助。谢谢。