开发者

how do i grab this from the xml?

开发者 https://www.devze.com 2023-03-18 03:06 出处:网络
How do i grab the link href (under the published node) from this xml: <entry> <id>tag:search.twitter.com,2005:8927670fcdf59031552</id>

How do i grab the link href (under the published node) from this xml:

<entry>
<id>tag:search.twitter.com,2005:8927670fcdf59031552</id>
<published>2011-07-08T10:16:40Z</published>
<link type="text/html" href="http://twitter.com/username/statuses/892767c088fds031552" rel="alternate"/>
<title>dfdf</title>
<content type="html">fdf</content>
<updated>2011-07-08T10:16:40Z</updated>
<link type="image/png" href="http://a0.twimg.com/profile_images/14014071/RV_normal.JPG" rel="image"/>
<twitter:geo>
</twitter:geo>
<twitter:metadata>
  <twitter:result_type>recent</twitter:result_type>
</twitter:metadata>
<twitter:source>&lt;a href=&quot;http://www.tweetdeck.com&quot; rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;</twitter:source>
<twitter:lang>en</twitter:lang>
<author>
  <name></name>
  <uri></uri>
</author>

when I have this php:

 $xml = simplexml_load开发者_StackOverflow_file("http://search.twitter.com/search.atom?q=from%3Ausername&rpp=10");
        if($xml) {
                    $url = $xml->entry->link->href;
                      $status = $xml->entry->title;

Problem i see is that there's more than one link node and also there's more than one atrribute for the link node..


try this:

$xml->entry->link[0]->attributes()->href; //this is for the first href node


Try:

$url = $xml->entry->link[0]->href;
0

精彩评论

暂无评论...
验证码 换一张
取 消