private function makeHeader()
    {
        $out = '<?xml version="1.0" encoding="'.$this->encoding.'" ?>' . PHP_EOL;

        $prefixes = $this->getNamespacePrefixes();
        $attributes = array();
        $tagName = '';
        $defaultNamespace = '';

        if ($this->version == Feed::RSS2) {
            $tagName = 'rss';
            $attributes['version'] = '2.0';
        } elseif ($this->version == Feed::RSS1) {
            $tagName = 'rdf:RDF';
            $prefixes[] = 'rdf';
            $defaultNamespace = $this->namespaces['rss1'];
        } elseif ($this->version == Feed::ATOM) {
            $tagName = 'feed';
            $defaultNamespace = $this->namespaces['atom'];

            // Ugly hack to remove the 'atom' value from the prefixes array.
            $prefixes = array_flip($prefixes);
            unset($prefixes['atom']);
            $prefixes = array_flip($prefixes);
        }

        // Iterate through every namespace prefix and add it to the element attributes.
        foreach ($prefixes as $prefix) {
            if (!isset($this->namespaces[$prefix]))
                throw new InvalidOperationException('Unknown XML namespace prefix: \'' . $prefix . '\'.'
                    . ' Use the addNamespace method to add support for this prefix.');
            else
                $attributes['xmlns:' . $prefix] = $this->namespaces[$prefix];
        }

        // Include default namepsace, if required
        if (!empty($defaultNamespace))
            $attributes['xmlns'] = $defaultNamespace;

        $out .= $this->makeNode($tagName, '', $attributes, true);

        return $out;
    }
private function makeHeader()
    {
        $out = '<?xml version="1.0" encoding="'.$this->encoding.'" ?>' . PHP_EOL;

        $prefixes = $this->getNamespacePrefixes();
        $attributes = array();
        $tagName = '';
        $defaultNamespace = '';

        if ($this->version == Feed::RSS2) {
            $tagName = 'rss';
            $attributes['version'] = '2.0';
        } elseif ($this->version == Feed::RSS1) {
            $tagName = 'rdf:RDF';
            $prefixes[] = 'rdf';
            $defaultNamespace = $this->namespaces['rss1'];
        } elseif ($this->version == Feed::ATOM) {
            $tagName = 'feed';
            $defaultNamespace = $this->namespaces['atom'];

            // Ugly hack to remove the 'atom' value from the prefixes array.
            $prefixes = array_flip($prefixes);
            unset($prefixes['atom']);
            $prefixes = array_flip($prefixes);
        }

        // Iterate through every namespace prefix and add it to the element attributes.
        foreach ($prefixes as $prefix) {
            if (!isset($this->namespaces[$prefix]))
                throw new InvalidOperationException('Unknown XML namespace prefix: \'' . $prefix . '\'.'
                    . ' Use the addNamespace method to add support for this prefix.');
            else
                $attributes['xmlns:' . $prefix] = $this->namespaces[$prefix];
        }

        // Include default namepsace, if required
        if (!empty($defaultNamespace))
            $attributes['xmlns'] = $defaultNamespace;

        $out .= $this->makeNode($tagName, '', $attributes, true);

        return $out;
    }
private function makeHeader ( ) { $ out = '<?xml version="1.0" encoding="' . $ this -> encoding . '" ?>' . PHP_EOL ; $ prefixes = $ this -> getNamespacePrefixes ( ) ; $ attributes = array ( ) ; $ tagName = '' ; $ defaultNamespace = '' ; if ( $ this -> version == Feed :: RSS2 ) { $ tagName = 'rss' ; $ attributes [ 'version' ] = '2.0' ; } elseif ( $ this -> version == Feed :: RSS1 ) { $ tagName = 'rdf:RDF' ; $ prefixes [ ] = 'rdf' ; $ defaultNamespace = $ this -> namespaces [ 'rss1' ] ; } elseif ( $ this -> version == Feed :: ATOM ) { $ tagName = 'feed' ; $ defaultNamespace = $ this -> namespaces [ 'atom' ] ; // Ugly hack to remove the 'atom' value from the prefixes array. $ prefixes = array_flip ( $ prefixes ) ; unset ( $ prefixes [ 'atom' ] ) ; $ prefixes = array_flip ( $ prefixes ) ; } // Iterate through every namespace prefix and add it to the element attributes. foreach ( $ prefixes as $ prefix ) { if ( ! isset ( $ this -> namespaces [ $ prefix ] ) ) throw new InvalidOperationException ( 'Unknown XML namespace prefix: \'' . $ prefix . '\'.' . ' Use the addNamespace method to add support for this prefix.' ) ; else $ attributes [ 'xmlns:' . $ prefix ] = $ this -> namespaces [ $ prefix ] ; } // Include default namepsace, if required if ( ! empty ( $ defaultNamespace ) ) $ attributes [ 'xmlns' ] = $ defaultNamespace ; $ out .= $ this -> makeNode ( $ tagName , '' , $ attributes , true ) ; return $ out ; }
Returns the XML header and root element, depending on the feed type.

@access   private
@return   string  The XML header of the feed.
@throws   InvalidOperationException if an unknown XML namespace prefix is encountered.
Returns the XML header and root element depending on the feed type .