XML Deserialization lose item of arrays



I have to deserialize an xml... Here the step I do.



  1. I generate the XSD from the xml with xsd xxx.xml;

  2. Two XSD are generated. So, I generate c# classes with xsd x1.xsd x2.xsd /classes

  3. A .cs file is generated with all necessary classes inside it. I check the file. Everything seems ok.. I have one array where I could have more than 1 result.


  4. In my code I have one xml to deserialize (the one I used to generate the xsd) and I deserialize it with this code:


    public static T Deserialize(Stream xml) { XmlSerializer serializer = new XmlSerializer(typeof(T));



    T objectDeserialized = null;
    using (StreamReader reader = new StreamReader(xml))
    {
    objectDeserialized = serializer.Deserialize(reader) as T;
    }

    return objectDeserialized;


    }




What I obtain is an array with just one element, but xml has two element (I have checked on debug).. What can be the problem?


No comments:

Post a Comment