使用simplexml_load_file提取rss feed的完整列表

用户325313

我正在使用代码从ebay rss提要中提取项目,唯一的问题是它仅提取了一个项目。

我怀疑是由于造成的for each,但是在搜索了整个网站之后,我找不到解决方案。提要URL将输出8个项目(entriesPerPage = 8),如果您访问提要,则会看到完整的xml代码,但解析器仅得到一个项目。

<?php

$feedurl = "http://rest.ebay.com/epn/v1/find/item.rss?keyword=%28jewelry%2Ccraft%2Cclothing%2Cshoes%2Cdiy%29&sortOrder=BestMatch&programid=1&campaignid=5337945426&toolid=10039&listingType1=All&lgeo=1&topRatedSeller=true&hideDuplicateItems=true&entriesPerPage=8&feedType=rss";

$rss = simplexml_load_file($feedurl);

foreach ($rss->channel->item as $item) {

$link = $item->link;

$title = $item->title;

$description = $item->description;

}

?>
<div class="mainproductebayfloatright-bottom">
<div class="aroundebay">
<?
print "<div class=\"titleebay\">" . $title . "</div>";
print $description;
?>
</div>
</div>

?>
u_mulder

将html移入循环中,因为当前每次迭代都将覆盖您的变量,并且在循环结束后,您拥有的是最后一个xml-item的值:

foreach ($rss->channel->item as $item) {
    $link = $item->link;
    $title = $item->title;
    $description = $item->description;?>
    <div class="mainproductebayfloatright-bottom">
        <div class="aroundebay">
    <?php
        // simple title
        print "<div class=\"titleebay\">" . $title . "</div>";
        // title-link
        print "<a href=\"" . $link . "\">" . $title . "</div>";
        print $description;
    ?>
        </div>
    </div>
<?php
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用TPL Dataflow处理输入的完整列表?

使用python和tweepy的twitter“朋友”的完整列表

如何使用exists获取产品的完整列表?

如何使用nltk打印单词的完整列表?

simplexml_load_file无法从URL提取数据

是否有不能使用关键字参数调用的内置函数的完整列表?

是否有海龟图形使用的关键事件名称的完整列表?

使用xpath时遍历特定的lxml元素时获取属性的完整列表

在R中:为什么没有函数可以使用的每个参数的完整列表?

google-rich-snippets json-ld中使用的数据类型(@type)的完整列表

如何获得使用中的非标准存储库的完整列表?

如何使用JavaScript中的循环获取十六进制颜色数字的完整列表

使用simplexml_load_file解析xml并插入MySQL

想要使用cURL而不是SimpleXML_load_file()

simplexml_load_file 不会使用数组获取数据

Hadoop YARN版本可以使用的流式命令行选项的完整列表是什么?

如何使用“控制面板”中出现的Get-WmiObject获取“查看安装更新”的Windows的完整列表

如何在使用无限滚动加载的页面中抓取完整列表,其中请求的 URL 每次都相同

simplexml_load_file(): 无法启用加密

simplexml_load_file多个等于节点

PHP simplexml_load_file()清除缓存

PHP simplexml_load_file 不解析

遍历simplexml_load_file结果

JVM选项完整列表

Tput选项的完整列表

Laravel断言完整列表

如何使用 file_get_contents 或 simplexml_load_file 获取如下 XML 属性?

使用unset()删除XML中的节点;PHP / simplexml_load_file

日期范围的完整列表(全年)