function XML2Array(SimpleXMLElement $parent) {
$array = [];
foreach ($parent as $name => $element) {
($node = & $array[$name])
&& (1 === count($node) ? $node = [$node] : 1)
&& $node = & $node[];
$node = $element->count() ? $this->XML2Array($element) : trim($element);
}
return $array;
}