Mega Code Archive

 
Categories / C# Tutorial / XML
 

XmlTextReader

using System; using System.Xml; class MainClass {   static void Main(string[] args)   {     XmlTextReader reader = new XmlTextReader(@"C:\books.xml");          while (reader.Read())     {       if (reader.HasAttributes)       {         Console.WriteLine(reader.Name + " Attribute");         for (int i = 0; i < reader.AttributeCount; i++)         {           reader.MoveToAttribute(i);           Console.WriteLine("Nam: "+reader.Name +", Value: "+ reader.Value);         }         reader.MoveToElement();        }         }   } }