XmlDocument doc = new XmlDocument(); doc.LoadXml(""); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { Console.WriteLine(node.NodeType); // prints Element, Text, Element } text1
XmlDocument doc = new XmlDocument(); doc.LoadXml("This class belongs to the System.Xml package library."); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { // Do something with an element node } else if (node.NodeType == XmlNodeType.Text) { // Do something with a text node } // ... } text1