• DataTab转换XML XML转换DataTable 的类[转]


    public string ConvertDataTableToXML(DataTable xmlDS)   
            {   
                MemoryStream stream = null;   
                XmlTextWriter writer = null;   
                try  
                {   
                    stream = new MemoryStream();   
                    writer = new XmlTextWriter(stream, Encoding.Default);   
                    xmlDS.WriteXml(writer);   
                    int count = (int)stream.Length;   
                    byte[] arr = new byte[count];   
                    stream.Seek(0, SeekOrigin.Begin);   
                    stream.Read(arr, 0, count);   
                    return System.Text.Encoding.GetEncoding("gb2312").GetString(arr).Trim();   
                }   
                catch  
                {   
                    return String.Empty;   
                }   
                finally  
                {   
                    if (writer != null) writer.Close();   
                }   
            }   
      
            public DataSet ConvertXMLToDataSet(string xmlData)   
            {   
                StringReader stream = null;   
                XmlTextReader reader = null;   
                try  
                {   
                    DataSet xmlDS = new DataSet();   
                    stream = new StringReader(xmlData);   
                    reader = new XmlTextReader(stream);   
                    xmlDS.ReadXml(reader);   
                    return xmlDS;   
                }   
                catch (Exception ex)   
                {   
                    string strTest = ex.Message;   
                    return null;   
                }   
                finally  
                {   
                    if (reader != null)   
                        reader.Close();   
                }   
            }  
    
    
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/tchjl2007/archive/2010/01/06/5143608.aspx
    
  • 相关阅读:
    SCU 3133(博弈)
    SCU 3132(博弈)
    hdu 5183(hash)
    hdu3329(2次dfs)
    hdu5179(数位dp)
    zoj2314(有上下界的网络流)
    CF 519E(树上倍增求lca)
    hdu1251(Trie树)
    SCU 2009(数位dp)
    【Leetcode】Letter Combinations of a Phone Number
  • 原文地址:https://www.cnblogs.com/ant520/p/1977414.html
Copyright © 2020-2023  润新知