package com.kdanmobile.android.lib.material.tokens.base

import java.io.File
import javax.xml.parsers.SAXParserFactory

/**
 * @classname:
 * @author: LiuXiaoLong
 * @date: 2023/2/13
 * description:
 */
object XMLUtil {


    /**
     * 解析已存在的xml数据
     */
    fun getFileXmlData(file: File, defaultHandler: BaseXmlHandler): MutableMap<String, String> {
        try {
            val factory = SAXParserFactory.newInstance()
            val parser = factory.newSAXParser()
            parser.parse(file, defaultHandler)
            return defaultHandler.getExistsMapValues()
        }catch (e : Exception){
            logE("XmlUtil", msg = "XmlUtil.getFileXmlData 出现异常:${e.printStackTrace()}")
            return mutableMapOf()
        }
    }





}