using System.Xml; class Program { static void Main(string[] args) { using (XmlReader reader = XmlReader.Create("example.xml")) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { Console.WriteLine(reader.Name); } } } } }
using System.Xml; class Program { static void Main(string[] args) { string xmlString = "This example reads an XML string and extracts the inner text of the "element" element. The package/library for XmlReader is part of the .NET framework and does not require any external installation."; using (XmlReader reader = XmlReader.Create(new StringReader(xmlString))) { reader.ReadToFollowing("element"); Console.WriteLine(reader.ReadInnerXml()); } } } test