protected function prepareInsert($item) { if (empty($item)) { return; } if (is_string($item)) { $item = Entities::replaceAllEntities($item); $frag = $this->ownerDocument->createDocumentFragment(); try { $frag->appendXML($item); } catch (Exception $e) { } return $frag; } if ($item instanceof \DOMNode) { if ($item->ownerDocument !== $this->ownerDocument) { return $this->ownerDocument->importNode($item, true); } return $item; } }