Get XML Child Node - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get XML Child Node

Demo Code


using System.Text;
using System.Reflection;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Net;
using System.Drawing;
using System;/*from w w  w . j ava 2s. c om*/

public class Main{
        public static XmlNode GetChildNode(XmlNode parentNode, string childNodeName)
      {
         XmlNode foundChildNode = null;

         if (parentNode.HasChildNodes)
         {
            foreach (XmlNode childNode in parentNode.ChildNodes)
            {
               if (childNode.Name == childNodeName)
               {
                  foundChildNode = childNode;
                  break;
               }
            }
         }

         return foundChildNode;
      }
}

Related Tutorials