title: Deserializing XML Array in unity
body: <p>Im trying to deserialize an array of objects from a XML Document.
  The document built in the following structure:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;root&gt;
     &lt;element&gt;
        .....
     &lt;/element&gt;
    &lt;element&gt;
        .....
     &lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  <p>But for some reason Im having lots of problems doing so.
  This is my function which I call to deserialize it:</p>
  <pre><code>public static CardModel[] Load(string text)
          {
              XmlRootAttribute xRoot = new XmlRootAttribute();
              xRoot.ElementName = &quot;root&quot;;
              xRoot.IsNullable = true;
              
              XmlSerializer serializer = new XmlSerializer(typeof(CardModel[]),xRoot);
              StringReader reader = new StringReader(text);
              CardModel[] o = serializer.Deserialize(reader) as CardModel[];
              reader.Close();
              
              return o;
          }
  </code></pre>
  <p>And I am not sure if its done correctly or not. Because I know that in json you are unable to deserialize an array and you have to do some sort of &quot;hack&quot;.</p>
  <p>In the CardModel class (which is the element of the array) i use above the class the tag [XmlRoot(&quot;root&quot;)]. I have also tried to use [XmlRoot(&quot;element&quot;)] but still im getting stuck.</p>