Find Children XmlElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Find Children XmlElement

Demo Code


using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System;/*from   w w w . java 2  s .c  o  m*/

public class Main{
        public static List<XmlElement> FindChildren(XmlElement parent, string childNodeName){
         List<XmlElement> ret = new List<XmlElement> ();
         foreach (XmlNode node in parent.ChildNodes) {
            if (node.NodeType == XmlNodeType.Element && node.Name == childNodeName) {
               ret.Add( (XmlElement)node );
            }
         }
         return ret; // Return whatever we found.
      }
}

Related Tutorials