<?php

################################################### FUNCTION: xml_random_child #
function xml_random_child($xml_file)
{
	$xml = xml_get_from_file($xml_file);
	$children = $xml->children();
	$count = count($children);
	
	return($children[rand(0,$count-1)]);
}

################################################## FUNCTION: xml_get_from_file #
function xml_get_from_file($file_path)
{
	if(!file_exists($file_path))
	{
		trigger_error('XML file "'.$file_path.'" does not exist!');
		return NULL;
	}
	
	return simplexml_load_file($file_path);
}

?>