protected static function arrayToXML($data, &$xml = null){

            if($xml === null)
                $xml = new \SimpleXMLElement("<?xml version=\"1.0\"?><nondb></nondb>");
            foreach($data as $k=>$v){
                if(is_array($v)){
                    $sub = $xml->addChild("$k");
                    self::arrayToXML($v, $sub);
                }else{
                    $xml->addChild("$k", htmlspecialchars("$v"));
                }
            }

            return $xml->asXML();

        }
protected static function arrayToXML($data, &$xml = null){

            if($xml === null)
                $xml = new \SimpleXMLElement("<?xml version=\"1.0\"?><nondb></nondb>");
            foreach($data as $k=>$v){
                if(is_array($v)){
                    $sub = $xml->addChild("$k");
                    self::arrayToXML($v, $sub);
                }else{
                    $xml->addChild("$k", htmlspecialchars("$v"));
                }
            }

            return $xml->asXML();

        }
protected static function arrayToXML ( $ data , & $ xml = null ) { if ( $ xml === null ) $ xml = new \ SimpleXMLElement ( "<?xml version=\"1.0\"?><nondb></nondb>" ) ; foreach ( $ data as $ k => $ v ) { if ( is_array ( $ v ) ) { $ sub = $ xml -> addChild ( "$k" ) ; self :: arrayToXML ( $ v , $ sub ) ; } else { $ xml -> addChild ( "$k" , htmlspecialchars ( "$v" ) ) ; } } return $ xml -> asXML ( ) ; }
Turn array to XML

@param array $data
@param \SimpleXMLElement &$xml

@return string
Turn array to XML