Warning: I wrote this code of the top of my head. I believe this will work, however, i couldn't test it because my php (v. 4.1.0) is installed on Windows 2000 and the DOMXML extension doesn't work on Windows.
$xmlfile = "quotes.xml";
//parse the xml file and return the DOM object.
$dom = xmldocfile($xmlfile);
if(!$dom) {
print('Error parsing xml file.');
exit;
}
//get the children of the root node (all the quote nodes in quotes)
$root = $dom->root();
$all_quotes = $root->children();
//pick a random number from 0 to however many quotes there are.
mt_srand((double)microtime() * 1000000);
$i = mt_rand(0, sizeof($all_quotes));
//Use the random number to get the quote.
$quote = $all_quotes[$i];
//Go print out the text.
$nodes = $quote->children();
while($node = array_shift($nodes)) {
if($node->name == "TEXT") {
print("TEXT: $node->content");
}
if($node->name == "SOURCE") {
print("SOURCE: $node->content");
}
}
hope this helps you.
BT