protected function getNodes(\DOMElement $node)
{
$xpath = new Xpath($node->ownerDocument);
$hasText = $xpath->evaluate('count(text()[normalize-space(.) != ""]) > 0', $node);
$hasElements = $xpath->evaluate('count(*) > 0', $node);
$attributes = new \stdClass();
$this->addAttributes($attributes, $node, $xpath);
$this->addNamespaces($attributes, $node, $xpath);
$attributes = (array) $attributes;
if ($hasText && $hasElements) {
return $this->getNodesArray($node, $attributes, $xpath);
} elseif ($hasText && count($attributes) === 0) {
return $node->nodeValue;
} else {
return parent::getNodes($node);
}
}