XML To DataTable - CSharp System.Xml

CSharp examples for System.Xml:XML DataSet

Description

XML To DataTable

Demo Code


using System.IO;//w ww  . ja v  a 2 s  . co m
using System.Data;
using System.Collections;

public class Main{
        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