src/thinkextend/transform/driver/Xml.php
public static function xml2data(SimpleXMLElement $xml, &$data, $item = 'item', $id = 'id')
    {
        foreach ($xml->children() as $items) {
            $key  = $items->getName();
            $attr = $items->attributes();
            if ($key == $item && isset($attr[$id])) {
                $key = strval($attr[$id]);
            }

            if ($items->count()) {
                self::xml2data($items, $val);
            } else {
                $val = strval($items);
            }

            $data[$key] = $val;
        }
    }
public static function xml2data(SimpleXMLElement $xml, &$data, $item = 'item', $id = 'id')
    {
        foreach ($xml->children() as $items) {
            $key  = $items->getName();
            $attr = $items->attributes();
            if ($key == $item && isset($attr[$id])) {
                $key = strval($attr[$id]);
            }

            if ($items->count()) {
                self::xml2data($items, $val);
            } else {
                $val = strval($items);
            }

            $data[$key] = $val;
        }
    }
数据XML解码
@static
@access public
@param  SimpleXMLElement $xml  xml对象
@param  array            $data 解码后的数据
@param  string           $item 数字索引时的节点名称
@param  string           $id   数字索引key转换为的属性名