I found the xml2array function below very useful, but there seems to be a bug in it. The $item variable was never getting set. I've expanded this out to be a bit more readable, and the corrected code is :
function xmlToArray($n)
{
$return=array();
foreach($n->childNodes as $nc){
if( $nc->hasChildNodes() ){
if( $n->firstChild->nodeName== $n->lastChild->nodeName&&$n->childNodes->length>1){
$item = $n->firstChild;
$return[$nc->nodeName][]=$this->xmlToArray($item);
}
else{
$return[$nc->nodeName]=$this->xmlToArray($nc);
}
}
else{
$return=$nc->nodeValue;
}
}
return $return;
}