I'm trying to load ";" in a Xml document to my form at the code worked fine until yesterday when I got the error message below for some reson, I haden't made any changes to the code.
Error: "An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll Additional information: Data at the root level is invalid. Line 1, position 1."
The Code:
XmlDocument myContacts = new XmlDocument();
string path = "C:\\Users\\Name\\\mycontacts.xml";
private void LoadContacts()
{
myContacts.LoadXml(path);
foreach (XmlNode node in myContacts.SelectNodes("Contacts/Contact"))
{
lstContacts.Items.Add(node.SelectSingleNode("Name").InnerText);
}
}
I've tried Linq (XDocument) to but get the same problem there but at ";" in the Program.cs Main.
Application.Run(new Form1());
I've googled around and tried James Schubert's solution with no result.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<Contacts>
<Contact>
<Name>Testing</Name>
<Email>test@gmail.com</Email>
<Phone>070 00 00 000</Phone>
<Street>Test A1</Street>
<Zip>000 00</Zip>
<Town>Testing</Town>
</Contact>
</Contacts>
I know there's lots of threads on the topic already but can't get any of their answers/solutions to work.
Is there any more "magic" ways to deal with this problem than the ones I've been able to find when searching for solutions?