there my XMl file :
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="XnaCzyMap.Element[]">
<Element>
<id>5</id>
<pos_x>54</pos_x>
<pos_y>30</pos_y>
<rot>90</rot>
</Element>
<Element>
<id>5</id>
<pos_x>54</pos_x>
<pos_y>165</pos_y>
<rot>90</rot>
</Element>
<Element>
<id>5</id>
<pos_x>54</pos_x>
<pos_y>340</pos_y>
<rot>25</rot>
</Element>
</Asset>
</XnaContent>
And my class :
public class Element
{
[System.Xml.Serialization.XmlElement("id")]
public int id { get; set; }
[System.Xml.Serialization.XmlElement("pos_x")]
public int pos_x { get; set; }
[System.Xml.Serialization.XmlElement("pos_y")]
public int pos_y { get; set; }
[System.Xml.Serialization.XmlElement("rot")]
public int rot { get; set; }
}
I want to Deserialize my XML as a collection of "Element". it worked when i didn't use XNA, but its not working anymore. VS give me the following error : Error 1 There was an error while deserializing intermediate XML. Cannot find type "XnaCzyMap.Element".
I have tried to add a collection as class but don"t work either.
[System.Xml.Serialization.XmlRoot("XnaContent")]
public class Elements
{
[XmlElement("Element")]
public List<Element> listObjet { get; set; }
}
What is the difference between deserialize using Xna or not ?
The code that do the deserialization :
public void load_map(string path)
{
XmlSerializer serializer = new XmlSerializer(typeof(Element[]));
StreamReader reader = new StreamReader(path);
try
{
file = (Element[])serializer.Deserialize(reader);
}
catch (Exception e)
{
}
reader.Close();
}
I have tried to switch "Element[]" by "Elements" when i tried with "Elements class"