I am trying to read Xml file through XmlReader but it gives exception as System.IO.FileNotFoundException: Could not find file "/Perls.xml".Following is my code:
using (XmlReader reader = XmlReader.Create("Perls.xml"))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "perls":
System.Diagnostics.Debug.WriteLine("Start <perls> element.");
break;
case "article":
System.Diagnostics.Debug.WriteLine("Start <article> element.");
string attribute = reader["name"];
if (attribute != null)
{
System.Diagnostics.Debug.WriteLine(" Has attribute name: " + attribute);
}
if (reader.Read())
{
System.Diagnostics.Debug.WriteLine(" Text node: " + reader.Value.Trim());
}
break;
}
}
}