getting a column from a XmlNodeList. - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

getting a column from a XmlNodeList.

Demo Code


using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;//from  w  w w .  j av  a2  s .  c om

public class Main{
        #endregion

      #region Conversion to Array
        
      /// <summary>
      /// This method same as getting a column from a table. 
      /// </summary>
      /// <param name="nodeList"></param>
      /// <param name="attributeName"></param>
      /// <returns></returns>
      public static string[] GetAttributeArray( XmlNodeList nodeList, string attributeName ) 
      { 
         string[] arrayOfValues = null; 
         if ( nodeList.Count > 0 ) 
         { 
            arrayOfValues = new string[nodeList.Count]; 
            int index = 0; 
            XmlNode node;
            foreach ( XmlNode n in nodeList ) 
            { 
               node = n;
               arrayOfValues[index] = GetAttributeValue( node, attributeName ); 
               index += 1; 
            }
         } 
         return arrayOfValues; 
      }
}

Related Tutorials