Gets only the values of the nodes passed in XML nodelist - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Gets only the values of the nodes passed in XML nodelist

Demo Code


using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;//from  w w  w .j a  v  a2s  . c om

public class Main{
        /// <summary>
      /// // Gets only the values of the nodes passed in nodelist
      /// </summary>
      /// <param name="nodeList"></param>
      /// <returns></returns>
      public static string[] GetArray( XmlNodeList nodeList )
      { 
         string[] arrayOfValues = null; 
         if ( nodeList.Count > 0 ) 
         { 
            arrayOfValues = new string[nodeList.Count]; 
            int index = 0; 
            foreach ( System.Xml.XmlNode node in nodeList ) 
            { 
               arrayOfValues[index] = node.InnerText; 
               index += 1; 
            }
         } 
         return arrayOfValues; 
      }
}

Related Tutorials