public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true )
    {
        $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null;

        if ( null !== $rootName )
        {
            $_xml .= Markup::openTag( $rootName );
        }

        $_string = null;

        if ( $data instanceof \Traversable )
        {
            foreach ( $data as $_key => $_value )
            {
                if ( is_numeric( $_key ) )
                {
                    $_key = $nodeName ?: 'node';
                }

                $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) );
            }
        }
        else
        {
            $_string = htmlspecialchars( $data, ENT_QUOTES );
        }

        //	Add the converted XML
        $_xml .= $_string;

        if ( null !== $rootName )
        {
            $_xml .= Markup::closeTag( $rootName );
        }

        return $_xml;
    }
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true )
    {
        $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null;

        if ( null !== $rootName )
        {
            $_xml .= Markup::openTag( $rootName );
        }

        $_string = null;

        if ( $data instanceof \Traversable )
        {
            foreach ( $data as $_key => $_value )
            {
                if ( is_numeric( $_key ) )
                {
                    $_key = $nodeName ?: 'node';
                }

                $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) );
            }
        }
        else
        {
            $_string = htmlspecialchars( $data, ENT_QUOTES );
        }

        //	Add the converted XML
        $_xml .= $_string;

        if ( null !== $rootName )
        {
            $_xml .= Markup::closeTag( $rootName );
        }

        return $_xml;
    }
public static function fromArray ( $ data , $ rootName = null , $ nodeName = null , $ addHeader = true ) { $ _xml = true === $ addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null ; if ( null !== $ rootName ) { $ _xml .= Markup :: openTag ( $ rootName ) ; } $ _string = null ; if ( $ data instanceof \ Traversable ) { foreach ( $ data as $ _key => $ _value ) { if ( is_numeric ( $ _key ) ) { $ _key = $ nodeName ? : 'node' ; } $ _string .= Markup :: tag ( $ _key , array ( ) , static :: fromArray ( $ _value , $ nodeName ) ) ; } } else { $ _string = htmlspecialchars ( $ data , ENT_QUOTES ) ; } //	Add the converted XML $ _xml .= $ _string ; if ( null !== $ rootName ) { $ _xml .= Markup :: closeTag ( $ rootName ) ; } return $ _xml ; }
Converts an array to an XML string

@param mixed  $data
@param string $rootName
@param string $nodeName
@param bool   $addHeader

@return null|string
Converts an array to an XML string