Child Element Count - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Child Element Count

Demo Code


using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from  w w  w. j  a  v  a2  s .  co  m

public class Main{
        public static int ChildElementCount(this XmlElement element)
        {
            int count = 0;
            foreach (XmlNode child in element.ChildNodes)
            {
                if (child is XmlElement)
                    count++;
            }
            return count;
        }
}

Related Tutorials