从XML获取3个URL,随机选择一个保存到变量

I'm in over my head at this point - but what i have currently looks like this:

<?php
    $request_url = "http://aethereverywhere.tumblr.com/api/read?type=photo&tagged=ae&start=0&num=1";
    $xml = simplexml_load_file($request_url);
    $img = $xml->posts->post->{'photo-url'};
?>

If increase &num to 3, lets say - it'll pull three files, and simplexml_load_file will parse them out - and save them to $img - but what i'd like to is have only one URL saved to $img, selected at random.

Thanks for the help

New code: select a random image from 0 to 118 (total 119), then outputing, choose the highest resolution.

<?php
    $request_url = "http://aethereverywhere.tumblr.com/api/read?type=photo&start=".rand(0,118);
    $xml = simplexml_load_file($request_url);
    $img = $xml->posts->post->{'photo-url'};
    $img=(array)$img;

    echo '<img src="'.$img[0].'">';
?>

Add a random number between 0 and the total photos -1. ie, get it in one line randomly.

$img = $xml->posts->post->{'photo-url'}[$random] // if that's the right syntax.

Or while iterating through the tags, do a random check for an even/odd number.

$img = (empty($img) || !$img) ? (rand(10)%2==0) ? $PHOTO_URL : FALSE : $img;

Do it like this:

$xml = simplexml_load_string($x); // assuming XML in $x, or use simplexml_load_file
$urls = $xml->xpath("//photo-url"); // get all <photo-url> nodes

echo $urls[rand(0,count($urls)-1)]; // echo a random url

see it working: http://codepad.viper-7.com/WDq0ha