document = new DOMDocument(); // Check if we should format the document later if ( $this->options->indentXml ) { $this->document->preserveWhiteSpace = false; $this->document->formatOutput = true; } $this->document->loadXml( $string ); $errors = ( $this->options->failOnError ? libxml_get_errors() : null ); libxml_clear_errors(); libxml_use_internal_errors( $oldXmlErrorHandling ); // If there are errors and the error handling is activated throw an // exception with the occured errors. if ( $errors ) { throw new ezcDocumentErroneousXmlException( $errors ); } } /** * Construct directly from DOMDocument * * To save execution time this method offers the construction of XML * documents directly from a DOM document instance. * * @param DOMDocument $document * @return void */ public function loadDomDocument( DOMDocument $document ) { $this->document = $document; } /** * Set DOMDocument * * Directly set the internally stored DOMDocument object, to spare * additional XML parsing overhead. Setting a broken or invalid docbook * document is not checked here, ebcause validation would cost too much * performace on each set. Be careful what you set here, invalid documents * may lead to unpredictable errors. * * @param DOMDocument $document * @return void */ public function setDomDocument( DOMDocument $document ) { $this->document = $document; } /** * Get DOMDocument * * Directly return the internally stored DOMDocument object, to spare * additional XML parsing overhead. * * @return DOMDocument */ public function getDomDocument() { return $this->document; } /** * Return document as string * * Serialize the document to a string an return it. * * @return string */ public function save() { return $this->document->saveXml(); } } ?>