Think/Template/TagLib.php
public function parseXmlAttr($attr = '', $tag = '')
    {
        //XML解析安全过滤
        $attr = str_replace('&', '___', $attr);
        $xml = '<tpl><tag '.$attr.' /></tpl>';
        $xml = \simplexml_load_string($xml);
        if (!$xml) {
            throw new BaseException(L('_XML_TAG_ERROR_').' : '.$attr);
        }
        /** @noinspection PhpUndefinedFieldInspection */
        $xml = (array)($xml->tag->attributes());
        if (isset($xml['@attributes'])) {
            $array = array_change_key_case($xml['@attributes']);
            if ($array) {
                $tag = strtolower($tag);
                if (!isset($this->tags[$tag])) {
                    // 检测是否存在别名定义
                    foreach ($this->tags as $val) {
                        if (isset($val['alias']) && in_array($tag, explode(',', $val['alias']))) {
                            $item = $val;
                            break;
                        }
                    }
                } else {
                    $item = $this->tags[$tag];
                }
                $attrs = explode(',', $item['attr']);
                if (isset($item['must'])) {
                    $must = explode(',', $item['must']);
                } else {
                    $must = [];
                }
                foreach ($attrs as $name) {
                    if (isset($array[$name])) {
                        $array[$name] = str_replace('___', '&', $array[$name]);
                    } elseif (false !== array_search($name, $must)) {
                        throw new BaseException(L('_PARAM_ERROR_').':'.$name);
                    }
                }

                return $array;
            }
        } else {
            return [];
        }
    }
public function parseXmlAttr($attr = '', $tag = '')
    {
        //XML解析安全过滤
        $attr = str_replace('&', '___', $attr);
        $xml = '<tpl><tag '.$attr.' /></tpl>';
        $xml = \simplexml_load_string($xml);
        if (!$xml) {
            throw new BaseException(L('_XML_TAG_ERROR_').' : '.$attr);
        }
        /** @noinspection PhpUndefinedFieldInspection */
        $xml = (array)($xml->tag->attributes());
        if (isset($xml['@attributes'])) {
            $array = array_change_key_case($xml['@attributes']);
            if ($array) {
                $tag = strtolower($tag);
                if (!isset($this->tags[$tag])) {
                    // 检测是否存在别名定义
                    foreach ($this->tags as $val) {
                        if (isset($val['alias']) && in_array($tag, explode(',', $val['alias']))) {
                            $item = $val;
                            break;
                        }
                    }
                } else {
                    $item = $this->tags[$tag];
                }
                $attrs = explode(',', $item['attr']);
                if (isset($item['must'])) {
                    $must = explode(',', $item['must']);
                } else {
                    $must = [];
                }
                foreach ($attrs as $name) {
                    if (isset($array[$name])) {
                        $array[$name] = str_replace('___', '&', $array[$name]);
                    } elseif (false !== array_search($name, $must)) {
                        throw new BaseException(L('_PARAM_ERROR_').':'.$name);
                    }
                }

                return $array;
            }
        } else {
            return [];
        }
    }
TagLib标签属性分析 返回标签属性数组
@access   public

@param string $attr
@param string $tag
@return array
@throws BaseException