src/thinkextend/transform/driver/Xml.php
public function encode($data, array $config = [])
    {
        //初始化配置
        $config = array_merge($this->config, $config);

        //创建XML对象
        $xml = new \SimpleXMLElement("<{$config['root_name']}></{$config['root_name']}>");
        self::data2xml($xml, $data, $config['item_name'], $config['item_key']);
        return $xml->asXML();
    }
public function encode($data, array $config = [])
    {
        //初始化配置
        $config = array_merge($this->config, $config);

        //创建XML对象
        $xml = new \SimpleXMLElement("<{$config['root_name']}></{$config['root_name']}>");
        self::data2xml($xml, $data, $config['item_name'], $config['item_key']);
        return $xml->asXML();
    }
编码XML数据
@param  mixed $data   被编码的数据
@param  array $config 数据配置项
@return string        编码后的XML数据