Find Child in XmlElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Find Child in XmlElement

Demo Code


using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System;/*from  www.j a v a 2 s.c  om*/

public class Main{
        public static XmlElement FindChild(XmlElement parent, string childNodeName){
         foreach (XmlNode node in parent.ChildNodes) {
            if (node.NodeType == XmlNodeType.Element && node.Name == childNodeName) {
               return (XmlElement)node;
            }
         }
         return null; // couldn't find it.
      }
}

Related Tutorials