convert it to an array and use shuffle? or count the items in the simplexml file and push each # into an array and shuffle that then use it to loop through the xml. like so (untested but basic idea should work) : <?php $xml = simplexml_load_file($yourfile); $xml_cnt = count($xml->items); $allitems = range(0,$xml_cnt); $all = shuffle($allitems); foreach($all as $curr) { // output here. } ?> Code (markup):