Get Xml First Child Node - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get Xml First Child Node

Demo Code


using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from  ww  w  . ja v a  2  s  .  c  o  m

public class Main{
        public static XmlNode GetXmlFirstChildNode(XmlNode  parentNode)
        {
            XmlNodeList childNodes = parentNode.ChildNodes;
            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlNode currNode = childNodes[i];
                if (currNode.NodeType == XmlNodeType.Element)
                {
                    return currNode;
                }
            }
            return null;
        }
}

Related Tutorials