protected function finalizeWrite(\XMLWriter $writer)
    {
        $writer->endDocument();
        $result = $writer->outputMemory(true);

        if (!$this->indent) {
            // Remove the XML declaration for an even
            // more compact result.
            if (!strncmp($result, '<'.'?xml', 5)) {
                $pos    = strpos($result, '?'.'>');
                if ($pos !== false) {
                    $result = (string) substr($result, $pos + 2);
                }
            }
            // Remove leading & trailing whitespace.
            $result = trim($result);
        }

        return $result;
    }
protected function finalizeWrite(\XMLWriter $writer)
    {
        $writer->endDocument();
        $result = $writer->outputMemory(true);

        if (!$this->indent) {
            // Remove the XML declaration for an even
            // more compact result.
            if (!strncmp($result, '<'.'?xml', 5)) {
                $pos    = strpos($result, '?'.'>');
                if ($pos !== false) {
                    $result = (string) substr($result, $pos + 2);
                }
            }
            // Remove leading & trailing whitespace.
            $result = trim($result);
        }

        return $result;
    }
protected function finalizeWrite ( \ XMLWriter $ writer ) { $ writer -> endDocument ( ) ; $ result = $ writer -> outputMemory ( true ) ; if ( ! $ this -> indent ) { // Remove the XML declaration for an even // more compact result. if ( ! strncmp ( $ result , '<' . '?xml' , 5 ) ) { $ pos = strpos ( $ result , '?' . '>' ) ; if ( $ pos !== false ) { $ result = ( string ) substr ( $ result , $ pos + 2 ) ; } } // Remove leading & trailing whitespace. $ result = trim ( $ result ) ; } return $ result ; }
This method must be called when the document
is complete and returns the document.

\param XMLWriter $writer
XML writer used to produce the document.

\retval string
The XML document that was generated,
as serialized XML.
This method must be called when the document is complete and returns the document .