public function getContentNodes($content, $includeTextNodes = TRUE, $limit = -1) { $result = FALSE; if ($nodes = $this->getNodeList($content, $includeTextNodes, $limit)) { $result = $nodes; } elseif (is_string($content)) { $result = $this->getFragment($content, $this->getOwner()->contentType, $includeTextNodes, $limit); } if (!is_array($result) || empty($result)) { throw new \InvalidArgumentException('Invalid/empty content parameter.'); } else { //if a node is not in the current document import it $document = $this->getOwner()->getDocument(); foreach ($result as $index => $node) { if ($node->ownerDocument !== $document) { $result[$index] = $document->importNode($node, TRUE); } } } return $result; }