Mega Code Archive

 
Categories / C# / XML
 

XmlReader MoveToFirstAttribute moves to the first attribute

using System; using System.IO; using System.Xml; public class Sample {     public static void Main()     {         XmlReader reader = XmlReader.Create("book.xml");         reader.ReadToDescendant("book");         reader.ReadToFollowing("book");         reader.MoveToFirstAttribute();         string genre = reader.Value;         Console.WriteLine("The genre value: " + genre);     } }