Hi, I'm getting an error when trying to deserialize my XML file.
The error message is "There is an error in XML document (2, 2)."

Below is the code in question and the XML file.

Could someone please explain why this is?

Thanks in advance!

<?xml version="1.0" encoding="utf-8"?>
<Objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

The file manager class

public List<Objects> loadObs(string theFileName)
            List<Objects> obs;

            XmlSerializer serializer = new XmlSerializer(typeof(List<Objects>));     

            StreamReader reader = new StreamReader(theFileName);                       

            obs = (List<Objects>)serializer.Deserialize(reader);                    


            return obs;

The Objects class

public class Objects

        public string ObjectID { get; set; }
        public string ObjectColor { get; set; }
        public string ObjectName { get; set; }

        public override string ToString()
            return ObjectName + " " + ObjectColor;

never mind.

turns out you need to say <ArrayOfObjects> in the xml file..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.