-1

How to check whether any data is returned in Object $twitter_xml for query abc or its empty?

Following is the code:

 $url="http://search.twitter.com/search.rss?q=abc";
 $twitter_xml = simplexml_load_file($url); 
1
  • You will always get an XML response. What element are you looking for in it? Commented Feb 23, 2012 at 11:33

2 Answers 2

1

This will give you a count of items:

count($twitter_xml->channel->item);
Sign up to request clarification or add additional context in comments.

Comments

0

I'm not sure what Twitter returns, but you should be able to do an isset() on a value you expect to exist.

See http://php.net/manual/en/function.isset.php

E.g.

if(isset($twitter_xml->name))
{
    // XML has a 'name' element
}
else
{
    // No 'name' element
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.