static void Main(string[] args) { String URLString = "c:\\books.xml"; XmlTextReader reader = new XmlTextReader(URLString); reader.WhitespaceHandling = WhitespaceHandling.None; while (reader.Read()) { switch(reader.NodeType) { case XmlNodeType.Element: //The node is an element. Console.Write("<" + reader.Name); while (reader.MoveToNextAttribute()) //Read the attributes. Console.Write(" " + reader.Name + "='" + reader.Value + "'"); Console.Write(">"); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine(reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } }The error message is:
<?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book genre="autobiography"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin</first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <book genre="philosophy"> <title>The Gorgias</title> <author> <name>Plato</name> </author> <price>9.99</price> </book> </bookstore>Thanks for anyone helping me, Best wish and regards