Mega Code Archive

 
Categories / C# Tutorial / XML
 

Output child node inner text

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);         }     }