I have a simple XML file with an array of objects:
<?xml version="1.0" encoding="UTF-8"?>
<complexes>
<complex>
<name>NAME1</name>
</complex>
</complexes>
So I've made a class structure to suit it:
public complex[] complexes;
public class complex
{
public string name;
}
And I do parsing with the standard C# tools:
XmlSerializer reader = new XmlSerializer(typeof(complex[]));
StreamReader file = new StreamReader("test.xml");
complexes = (complex[])reader.Deserialize(file);
For some reason I get an exception on the last line:
System.InvalidOperationException: 'There is an error in XML document (2, 2).'
InvalidOperationException: <complexes xmlns=''> was not expected.
What's the issue?