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

CSharp examples for System.Xml:XML Node

Description

Creates Data columns given an XmlNode.

Demo Code

// All rights reserved.
using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;//from w  w w . j a  v  a2  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>
      protected static void CreateColumns(DataTable dt, XmlNode node)
      {
         foreach(XmlAttribute attr in node.Attributes)
         {
            dt.Columns.Add(new DataColumn(attr.Name));
         }
      }
}

Related Tutorials