我正在尝试将我的Wordpress Feed直接显示到我的外部magento站点 . 我正在使用feedburner来实现这一结果 . 到目前为止,我已经能够显示博客 Headers 和链接 . 为了改善外观,我还想在 Headers 旁边显示博客 .
这是我用来解析XML Feed的PHP代码,用于显示带链接的博客 Headers
<?php $channel = new Zend_Feed_Rss('http://feeds.feedburner.com/golfoy/pxce'); ?>
<div class="block block-rss">
<div class="block-content">
<ol id="graybox-latest-news">
<?php foreach ($channel as $item): ?>
<li><a href="<?php echo $item->link; ?>"><?php echo $item->description; ?></a></li>
<?php endforeach; ?>
</ol>
</div>
</div>
下面提到的是单个Feed项的XML代码 . 你可以在this URL找到完整的饲料
<item>
<title>The grey-haired major winners.</title>
<link>http://blog.golfoy.com/the-grey-haired-major-winners/</link>
<pubDate>Mon, 29 Aug 2016 08:24:53 +0000</pubDate>
<guid isPermaLink="false">http://blog.golfoy.com/?p=980</guid>
<description>
<![CDATA[<img width="300" height="169" src="http://blog.golfoy.com/wp-content/uploads/2016/08/17_Jack_Nicklaus_20130805165206236_2560_1706.vresize.1200.675.high_.43-300x169.jpg" />
You are never too old to hit the greens and play a round of golf. In the history of men’s major championships, no golfer older than 48 (and just one golfer older than 46) has won. Have a look at the list of oldest men to have won a major: 1.Ben Hogan: The legend won […]]]>
</description>
<content:encoded>
....
</content:encoded>
</item>
我试图捕获整个img标签或只是在Feed项的描述标签内的“src” . 这样做的最佳做法是什么?
1 回答
你在xml中选择描述并发送给get_images .
包括simple_html_dom.php download
并在函数中更改define(URL_IMAGE,PATH_UPLOAD) .
function get_images($ html)
选择说明