Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 另一个网站上的RSS提要_Php_Rss_Wordpress - Fatal编程技术网

Php 另一个网站上的RSS提要

Php 另一个网站上的RSS提要,php,rss,wordpress,Php,Rss,Wordpress,我这里有一个问题…我试图在我的网站上显示一个博客(wordpress)的提要…这是我得到的回报…我已经有了文章的图像、标题和链接…但是描述像一个xml对象…我试图阅读,但没有成功…有人可以帮助我 object(SimpleXMLElement)[74] public 'title' = string '10 curiosidades sobre a Pizza' (length=29) public 'link' = string 'www.site.com.br/blo

我这里有一个问题…我试图在我的网站上显示一个博客(wordpress)的提要…这是我得到的回报…我已经有了文章的图像、标题和链接…但是描述像一个xml对象…我试图阅读,但没有成功…有人可以帮助我

  object(SimpleXMLElement)[74]
    public 'title' =  string '10 curiosidades sobre a Pizza' (length=29)
    public 'link' =  string 'www.site.com.br/blog/index.php/10-curiosidades-sobre-a-pizza/' (length=71)
    public 'comments' =  string 'www.site.com.br/blog/index.php/10-curiosidades-sobre-a-pizza/#comments' (length=80)
    public 'pubDate' =  string 'Wed, 14 Aug 2013 13:08:49 +0000' (length=31)
    public 'category' =>
      object(SimpleXMLElement)[76]
    public 'guid' =  string 'www.site.com.br/blog/?p=1254' (length=38)
    public 'description' =  
      object(SimpleXMLElement)[75]
    public 'enclosure' =  
      object(SimpleXMLElement)[77]
        public '@attributes' =  
          array (size=3)
          'url' =  string 'www.site.com.br/blog/wp-content/uploads/2013/08/pizza-RC-Fones-150x150.jpg' (length=84)
          'length' =  string '9873' (length=4)
          'type' =  string 'image/jpg' (length=9)

您需要使用的方法来提取所需的信息。例如,要获取标题,请使用
$title=$object->title

其中一些项本身就是SimpleXMLElement对象。要从中获取信息,只需做同样的事情:

// assuming the description has a title...

$description = $object->description->title;

当我尝试获取description的属性时,返回另一个对象,我不知道为什么…当我尝试获取“enclosure”的属性时,它很好…RSS提要作为XML文档发布。XML是一种分层数据结构-一个元素可以有“子”元素,子元素可以有更多的子元素,等等。这些元素中的每一个都可以由
simplexmlement
的实例表示。要获取这些元素“内部”的数据,请使用
simplexmlement
类的方法和属性(答案中有指向文档的链接)。你可能需要做一些实验来得到你想要的值。