data inside xml string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
roice
Forum Commoner
Posts: 35
Joined: Tue Mar 02, 2010 9:14 am

data inside xml string

Post by roice »

Hello,
The following link will give you the number of the Inbound link to some url:
http://search.yahooapis.com/SiteExplore ... output=xml

In the top you can find "totalResultsAvailable=14370725"
how can I get the number into varibale?

I tried this:

Code: Select all

$resp = file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=YahooDemo&query=http://www.cnn.com&omit_inlinks=domain&output=xml");
$xml = simplexml_load_string($resp);
echo $xml->ResultSet['totalResultsAvailable'];
But its not working...:/
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Re: data inside xml string

Post by Technocrat »

You were SO close.

Code: Select all

$resp  = file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=YahooDemo&query=http://www.cnn.com&omit_inlinks=domain&output=xml");
$xml = simplexml_load_string($resp);
echo (string)$xml['totalResultsAvailable'];
roice
Forum Commoner
Posts: 35
Joined: Tue Mar 02, 2010 9:14 am

Re: data inside xml string

Post by roice »

Thank you,
It's working.
Post Reply