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><a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a></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;
精彩评论