Get Array from XmlNodeList - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get Array from XmlNodeList

Demo Code

// All rights reserved.
using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;/*w ww .  j  av  a 2s .co m*/

public class Main{
        // Gets only the values of the nodes passed in nodelist
      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