But it gives me exception like "There are multiple root elements. Line 3, position 2." on the line reader.MoveToContent();
Below is the sample code that i use
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sample
{
class Program
{
static void Main(string[] args)
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("C:\\Users\\ADMIN\\Pictures\\test.xml");
string contents = "";
while (reader.Read())
{
reader.MoveToContent();
if (reader.NodeType == System.Xml.XmlNodeType.Element)
contents += "<" + reader.Name + ">\n";
if (reader.NodeType == System.Xml.XmlNodeType.Text)
contents += reader.Value + "\n";
}
Console.Write(contents);
Console.ReadLine();
}
}
}
please help.