XML To Hashtable - CSharp System.Xml

CSharp examples for System.Xml:XML DataSet

Description

XML To Hashtable

Demo Code


using System.IO;// w w w . ja  v  a2  s .co m
using System.Data;
using System.Collections;

public class Main{
        public static Hashtable XMLToHashtable(string xmlData)
        {
            DataTable dt = XMLHelper.XMLToDataTable(xmlData);
            return DataTableHelper.DataTableToHashtable(dt);
        }
        public static DataTable XMLToDataTable(string xmlData)
        {
            DataTable result;
            if (!string.IsNullOrEmpty(xmlData))
            {
                DataSet ds = new DataSet();
                ds.ReadXml(new StringReader(xmlData));
                if (ds.Tables.Count > 0)
                {
                    result = ds.Tables[0];
                    return result;
                }
            }
            result = null;
            return result;
        }
}

Related Tutorials