Creates DataTable columns given an XmlNode. - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Creates DataTable columns given an XmlNode.

Demo Code

// All rights reserved.
using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;/*ww w .  j a va2  s. c  om*/

public class Main{
        /// <summary>
        /// Creates columns given an XmlNode.
        /// </summary>
        /// <param name="dt">The target DataTable.</param>
        /// <param name="node">The source XmlNode.</param>
        protected static void CreateColumns(DataTable dt, XmlNode node)
        {
            foreach (XmlAttribute attr in node.Attributes)
            {
                dt.Columns.Add(new DataColumn(attr.Name));
            }
        }
}

Related Tutorials