Php Rss提要在CDATA中使用img->;内容:编码
我只需要显示CDATA内容中的图像Php Rss提要在CDATA中使用img->;内容:编码,php,rss,feed,cdata,Php,Rss,Feed,Cdata,我只需要显示CDATA内容中的图像 <item> <title>... </title> <link>... </link> <description>... </description> <category>... </category> <pubDate>... </pubDate> <guid&
<item>
<title>... </title>
<link>... </link>
<description>... </description>
<category>... </category>
<pubDate>... </pubDate>
<guid>... </guid>
<content:encoded><![CDATA[<a href="..."><img alt="" src="..."/></a>...]]></content:encoded>
<enclosure url="..." type="image/jpeg" length="171228"></enclosure>
</item>
...
...
...
...
...
...
我试过的代码看起来很适合这个角色
<?php
$html = "";
$url = "http://www....";
$xml = simplexml_load_file($url);
for($i = 0; $i < 1; $i++){
//works fine with <description> part
$description = $xml->channel->item[$i]->description;
preg_match("/<img[^>]+\>/i", $description, $matches);
if (isset($matches[0])) {
$html .= $matches[0];
//echo "<br/>show img<br/>";
} else {
$html .= $description;
echo "<br/>there is no img";
}
}
echo $html;
?>
现在我需要一个方法的部分,并显示图像分开。
有人能帮我修一下吗
也许可以使用中的url来显示图像