protected function parseNode(\SimpleXMLElement $node)
{
$parsedNode = [];
if ($node->count() === 0) {
return (string) $node;
}
foreach ($node->children() as $child) {
$nameOfChild = $child->getName();
$parsedChild = $this->parseNode($child);
if (count($child->attributes()) > 0) {
$parsedAttributes = '';
foreach ($child->attributes() as $attributeName => $attributeValue) {
if ($this->isDistinguishingAttribute($attributeName)) {
$parsedAttributes .= '[@' . $attributeName . '="' . $attributeValue . '"]';
}
}
$nameOfChild .= $parsedAttributes;
}
if (!isset($parsedNode[$nameOfChild])) {
// We accept only first child when they are non distinguishable (i.e. they differs only by non-distinguishing attributes)
$parsedNode[$nameOfChild] = $parsedChild;
}
}
return $parsedNode;
}