Output child node inner text : XmlElement « XML « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

    public class MainClass
    {
        public static void Main()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("employees.xml");
            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                string employeeid = node.Attributes["employeeid"].Value;
                Console.WriteLine(employeeid);
            }

            XmlElement ele= doc.GetElementById("id");
            Console.WriteLine(ele.ChildNodes[0].InnerText);
            Console.WriteLine(ele.ChildNodes[1].InnerText);
            Console.WriteLine(ele.ChildNodes[2].InnerText);
            Console.WriteLine(ele.ChildNodes[3].InnerText);
        }
    }








30.14.XmlElement
30.14.1.Get node children count
30.14.2.Output child node inner text
30.14.3.Selecting single Node with SelectSingleNode as XmlElement