src/XmlElement.php
public function outerXml()
    {
        $attributes = '';
        foreach ($this->getAttributes() as $name => $value) {
            if ($value === null) {
                // Self-closing attribute format.
                $attributes .= " $name";
            } else {
                // Full attribute format.
                $value = addslashes($value);
                $attributes .= " $name=\"$value\"";
            }
        }

        // Self-closing element format.
        if ($this->getText() === null && count($this->getChildren()) == 0) {
            return "<{$this->getName()}$attributes/>";
        }

        // Full element format.
        return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>";
    }
public function outerXml()
    {
        $attributes = '';
        foreach ($this->getAttributes() as $name => $value) {
            if ($value === null) {
                // Self-closing attribute format.
                $attributes .= " $name";
            } else {
                // Full attribute format.
                $value = addslashes($value);
                $attributes .= " $name=\"$value\"";
            }
        }

        // Self-closing element format.
        if ($this->getText() === null && count($this->getChildren()) == 0) {
            return "<{$this->getName()}$attributes/>";
        }

        // Full element format.
        return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>";
    }
public function outerXml ( ) { $ attributes = '' ; foreach ( $ this -> getAttributes ( ) as $ name => $ value ) { if ( $ value === null ) { // Self-closing attribute format. $ attributes .= " $name" ; } else { // Full attribute format. $ value = addslashes ( $ value ) ; $ attributes .= " $name=\"$value\"" ; } } // Self-closing element format. if ( $ this -> getText ( ) === null && count ( $ this -> getChildren ( ) ) == 0 ) { return "<{$this->getName()}$attributes/>" ; } // Full element format. return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>" ; }
Get xml with root element.

@return string
Get xml with root element .