XML转换成DataTable

        #region XML转dataset
        //str 是xml字符串
        public static DataTable GetResultXMLToDataTable    (string str,string Dt_Name)
        {
            DataSet xmlDs = new DataSet("ds");
            StringReader stream = null;
            XmlTextReader reader = null;
            try
            {
                using (stream = new StringReader(str))
                {
                    using (reader = new XmlTextReader(stream))
                    {
                        xmlDs.ReadXml(reader);
                        return xmlDs.Tables[Dt_Name];
                    }
                }
            }
            catch (Exception ex)
            {
               //Get Exception
            }
            finally
            {
                if (reader != null)
                    reader.Close();
                if (stream != null)
                    stream.Close();
            }
            return null;
        }

        #endregion
原文地址:https://www.cnblogs.com/TechnologyDictionary/p/11445379.html