public function toXML()
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );
        $dom->formatOutput = true;
        $success = $dom->loadXML('<page />');

        $pageNode = $dom->documentElement;

        foreach ( $this->attributes as $attrName => $attrValue )
        {
            switch ( $attrName )
            {
                case 'id':
                    $pageNode->setAttribute( 'id', $attrValue );
                    break;

                case 'zones':
                    foreach ( $this->attributes['zones'] as $zone )
                    {
                        $zoneNode = $zone->toXML( $dom );
                        $pageNode->appendChild( $zoneNode );
                    }
                    break;

                default:
                    $node = $dom->createElement( $attrName );
                    $nodeValue = $dom->createTextNode( $attrValue );
                    $node->appendChild( $nodeValue );
                    $pageNode->appendChild( $node );
                    break;
            }
        }

        return $dom->saveXML();
    }
public function toXML()
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );
        $dom->formatOutput = true;
        $success = $dom->loadXML('<page />');

        $pageNode = $dom->documentElement;

        foreach ( $this->attributes as $attrName => $attrValue )
        {
            switch ( $attrName )
            {
                case 'id':
                    $pageNode->setAttribute( 'id', $attrValue );
                    break;

                case 'zones':
                    foreach ( $this->attributes['zones'] as $zone )
                    {
                        $zoneNode = $zone->toXML( $dom );
                        $pageNode->appendChild( $zoneNode );
                    }
                    break;

                default:
                    $node = $dom->createElement( $attrName );
                    $nodeValue = $dom->createTextNode( $attrValue );
                    $node->appendChild( $nodeValue );
                    $pageNode->appendChild( $node );
                    break;
            }
        }

        return $dom->saveXML();
    }
public function toXML ( ) { $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; $ dom -> formatOutput = true ; $ success = $ dom -> loadXML ( '<page />' ) ; $ pageNode = $ dom -> documentElement ; foreach ( $ this -> attributes as $ attrName => $ attrValue ) { switch ( $ attrName ) { case 'id' : $ pageNode -> setAttribute ( 'id' , $ attrValue ) ; break ; case 'zones' : foreach ( $ this -> attributes [ 'zones' ] as $ zone ) { $ zoneNode = $ zone -> toXML ( $ dom ) ; $ pageNode -> appendChild ( $ zoneNode ) ; } break ; default : $ node = $ dom -> createElement ( $ attrName ) ; $ nodeValue = $ dom -> createTextNode ( $ attrValue ) ; $ node -> appendChild ( $ nodeValue ) ; $ pageNode -> appendChild ( $ node ) ; break ; } } return $ dom -> saveXML ( ) ; }
Dumps object structure into XML type string

@return string
Dumps object structure into XML type string