classes/ezsolrdoc.php
function docToXML()
    {
        $this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
        $this->DomRootElement = $this->DomDoc->createElement( 'doc' );
        $this->DomDoc->appendChild( $this->DomRootElement );

        if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
        {
            // This will force the '.' as decimal separator and not depend on the locale
            $docBoost = sprintf('%F',$this->DocBoost);
            $this->DomRootElement->setAttribute( 'boost', $docBoost );
        }

        foreach ($this->Doc as $name => $field) {
            foreach( $field['content'] as $value )
            {
                // $value should never be array. Log the value and the stack trace.
                if ( is_array( $value ) )
                {
                    $backtrace = debug_backtrace();
                    $dump = array( $backtrace[0], $backtrace[1] );
                    eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
                                         "\nStack trace: " . var_export( $dump, 1 ) );
                    continue;
                }
                $fieldElement = $this->DomDoc->createElement( 'field' );
                $fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
                $fieldElement->setAttribute( 'name', $name );

                if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
                {
                    $fieldElement->setAttribute( 'boost', $field['boost'] );
                }

                $this->DomRootElement->appendChild( $fieldElement );
            }
        }


        $rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
        //make sure there are no control characters left that could currupt the XML string
        return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
    }
function docToXML()
    {
        $this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
        $this->DomRootElement = $this->DomDoc->createElement( 'doc' );
        $this->DomDoc->appendChild( $this->DomRootElement );

        if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
        {
            // This will force the '.' as decimal separator and not depend on the locale
            $docBoost = sprintf('%F',$this->DocBoost);
            $this->DomRootElement->setAttribute( 'boost', $docBoost );
        }

        foreach ($this->Doc as $name => $field) {
            foreach( $field['content'] as $value )
            {
                // $value should never be array. Log the value and the stack trace.
                if ( is_array( $value ) )
                {
                    $backtrace = debug_backtrace();
                    $dump = array( $backtrace[0], $backtrace[1] );
                    eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
                                         "\nStack trace: " . var_export( $dump, 1 ) );
                    continue;
                }
                $fieldElement = $this->DomDoc->createElement( 'field' );
                $fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
                $fieldElement->setAttribute( 'name', $name );

                if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
                {
                    $fieldElement->setAttribute( 'boost', $field['boost'] );
                }

                $this->DomRootElement->appendChild( $fieldElement );
            }
        }


        $rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
        //make sure there are no control characters left that could currupt the XML string
        return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
    }
function docToXML ( ) { $ this -> DomDoc = new DOMDocument ( '1.0' , 'utf-8' ) ; $ this -> DomRootElement = $ this -> DomDoc -> createElement ( 'doc' ) ; $ this -> DomDoc -> appendChild ( $ this -> DomRootElement ) ; if ( $ this -> DocBoost !== null && is_numeric ( $ this -> DocBoost ) ) { // This will force the '.' as decimal separator and not depend on the locale $ docBoost = sprintf ( '%F' , $ this -> DocBoost ) ; $ this -> DomRootElement -> setAttribute ( 'boost' , $ docBoost ) ; } foreach ( $ this -> Doc as $ name => $ field ) { foreach ( $ field [ 'content' ] as $ value ) { // $value should never be array. Log the value and the stack trace. if ( is_array ( $ value ) ) { $ backtrace = debug_backtrace ( ) ; $ dump = array ( $ backtrace [ 0 ] , $ backtrace [ 1 ] ) ; eZDebug :: writeError ( 'Tried to index array value: ' . $ name . "\nValue: " . var_export ( $ value , 1 ) . "\nStack trace: " . var_export ( $ dump , 1 ) ) ; continue ; } $ fieldElement = $ this -> DomDoc -> createElement ( 'field' ) ; $ fieldElement -> appendChild ( $ this -> DomDoc -> createTextNode ( $ value ) ) ; $ fieldElement -> setAttribute ( 'name' , $ name ) ; if ( $ field [ 'boost' ] !== null && is_numeric ( $ field [ 'boost' ] ) ) { $ fieldElement -> setAttribute ( 'boost' , $ field [ 'boost' ] ) ; } $ this -> DomRootElement -> appendChild ( $ fieldElement ) ; } } $ rawXML = $ this -> DomDoc -> saveXML ( $ this -> DomRootElement ) ; //make sure there are no control characters left that could currupt the XML string return preg_replace ( '@[\x00-\x08\x0B\x0C\x0E-\x1F]@' , ' ' , $ rawXML ) ; }
Convert current object to XML string

@return string XML string.
Convert current object to XML string