Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.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 web抓取从xml获取内容_Php - Fatal编程技术网

Php web抓取从xml获取内容

Php web抓取从xml获取内容,php,Php,如何使用php从xml页面获取内容。 内容如下: <entry> <title>News</title> <link rel="alternate" href="http://www.website.com/detail/2688327:BlogPost:1569917"/> <id>tag:www.website.com,2012-04-25:2688327:BlogPost:1569917</id&

如何使用php从xml页面获取内容。 内容如下:

 <entry>
   <title>News</title>
     <link rel="alternate" href="http://www.website.com/detail/2688327:BlogPost:1569917"/>
     <id>tag:www.website.com,2012-04-25:2688327:BlogPost:1569917</id>
     <updated>2012-04-25T08:30:00.000Z</updated>
     <author>
     <name>Username</name>
     <uri>http://www.website.com/profile/username</uri>
     </author>
      <summary type="html">
      Hi this is the latest news
      </summary>
</entry>

 <entry>
   <title>News2</title>
     <link rel="alternate" href="http://www.website.com/detail/2688327:BlogPost:1569917"/>
     <id>tag:www.website.com,2012-04-25:2688327:BlogPost:1569917</id>
     <updated>2012-04-25T08:30:00.000Z</updated>
     <author>
     <name>Username2</name>
     <uri>http://www.website.com/profile/username</uri>
     </author>
      <summary type="html">
      Hi this is the latest news
      </summary>
</entry>

 <entry>
   <title>News3</title>
     <link rel="alternate" href="http://www.website.com/detail/2688327:BlogPost:1569917"/>
     <id>tag:www.website.com,2012-04-25:2688327:BlogPost:1569917</id>
     <updated>2012-04-25T08:30:00.000Z</updated>
     <author>
     <name>Username3</name>
     <uri>http://www.website.com/profile/username</uri>
     </author>
      <summary type="html">
      Hi this is the latest news
      </summary>
</entry>

 <entry>
   <title>News4</title>
     <link rel="alternate" href="http://www.website.com/detail/2688327:BlogPost:1569917"/>
     <id>tag:www.website.com,2012-04-25:2688327:BlogPost:1569917</id>
     <updated>2012-04-25T08:30:00.000Z</updated>
     <author>
     <name>Username4</name>
     <uri>http://www.website.com/profile/username</uri>
     </author>
      <summary type="html">
      Hi this is the latest news
      </summary>
</entry>

新闻
标签:www.website.com,2012-04-25:2688327:BlogPost:1569917
2012-04-25T08:30:00.000Z
用户名
http://www.website.com/profile/username
嗨,这是最新消息
新闻2
标签:www.website.com,2012-04-25:2688327:BlogPost:1569917
2012-04-25T08:30:00.000Z
用户名2
http://www.website.com/profile/username
嗨,这是最新消息
新闻3
标签:www.website.com,2012-04-25:2688327:BlogPost:1569917
2012-04-25T08:30:00.000Z
用户名3
http://www.website.com/profile/username
嗨,这是最新消息
新闻4
标签:www.website.com,2012-04-25:2688327:BlogPost:1569917
2012-04-25T08:30:00.000Z
用户名4
http://www.website.com/profile/username
嗨,这是最新消息

如何使用php获取标题数组、博客链接、作者详细信息(如姓名和uri(配置文件链接)以及摘要?

请查看simplexml、xpath


检查simplexml,xpath

   $file = 'url or file name';
    $xml = simplexml_load_file('$file');
    $list= $xml->xpath("/entry"); // root/entry ...
    print $list[0]->id; 
    #var_dump($list);