public function __construct($DOMNode, $namespaces = array()) { //we insert the templated item after the reference node, //which will always be the last item that was templated $this->refNode = $DOMNode; //take a copy of the original node that we will use as a starting point each time we iterate $this->template = $DOMNode->cloneNode(true); //initialise the template with the current, original node parent::__construct($DOMNode, $namespaces); }
public function __toString() { //if the input was HTML, remove the XML prolog on output return $this->type == self::HTML ? preg_replace('/^<\\?xml[^<]*>\\n/', '', parent::__toString()) : parent::__toString(); }