private function getNodesArray(\DOMElement $node, $attributes, $xpath)
{
$result = [];
foreach ($attributes as $name => $value) {
$child = new \stdClass();
$child->{$name} = $value;
$result[] = $child;
}
foreach ($xpath->evaluate('*|text()[normalize-space(.) != ""]', $node) as $childNode) {
/** @var \DOMElement|\DOMText|\DOMCdataSection $childNode */
if ($childNode instanceof \DOMElement) {
$child = new \stdClass();
$child->{$childNode->nodeName} = $this->getNodes($childNode);
$result[] = $child;
} elseif (!$childNode->isWhitespaceInElementContent()) {
$result[] = $childNode->nodeValue;
}
}
return $result;
}