public static function XMLToArray(\SimpleXMLElement $sxml)
{
$output = [];
$singular_node_name = self::singularize($sxml->getName());
foreach ($sxml->children() as $child_name => $child) {
/**
* @var \SimpleXMLElement $child
*/
if ($child->count() > 0) {
$node = self::XMLToArray($child);
} else {
$node = (string) $child;
}
//don't make it assoc, as the keys will all be the same
if ($child_name === $singular_node_name) {
$output[] = $node;
} else {
$output[$child_name] = $node;
}
}
return $output;
}