C# 获取xml数据,并转换为dataset

//获取xml数据,并转换为dataset
public static DataSet getConfig(string strXmlPath)
{
    string filePath = GetPhysicalPath();
    DataSet ds= ConvertXMLFileToDataSet(GetXmlFullPath(filePath));
    return ds;
}
 //将xml文件转换为DataSet
public static DataSet ConvertXMLFileToDataSet(string xmlFile)
{
    StringReader stream = null;
    XmlTextReader reader = null;
    try
    {
        XmlDocument xmld = new XmlDocument();
        xmld.Load(xmlFile);
        DataSet xmlDS = new DataSet();
        stream = new StringReader(xmld.InnerXml);
        //从stream装载到XmlTextReader
        reader = new XmlTextReader(stream);
        xmlDS.ReadXml(reader);
        //xmlDS.ReadXml(xmlFile);
        return xmlDS;
    }
    catch (System.Exception ex)
    {
        throw ex;
    }
    finally
    {
        if (reader != null)
         reader.Close();
    }
}

上一篇:不断超越的调度系统:如何撑住9年双11交易峰值800倍增长


下一篇:Egg.js中复用静态页面逻辑、局部刷新架构、生成验证码