Creates columns given an XmlNode. - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Creates columns given an XmlNode.

Demo Code


using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;//from  w ww  . j  av  a 2 s  .  co  m

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

Related Tutorials