.net - Deserializing xml into an ArrayList of objects in C# -
the following xml result of serializing arraylist of asset objets
<arrayofasset xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <asset> <name>bill</name> <type>perosn</type> </asset> <asset> <name>bill</name> <type>perosn</type> </asset> </arrayofasset>
i can deserialize default c# deserializer no problem. if root element changes arrayofasset assets, deserializer blows up. how can make deserializer aware of change.
here deserialization code:
streamreader sr = new streamreader("c:\\assest.xml"); string r = sr.readtoend(); list<asset> list; type[] extratypes = new type[1]; extratypes[0] = typeof(asset); system.xml.serialization.xmlserializer serializer = new system.xml.serialization.xmlserializer(typeof(list<asset>), extratypes); object obj = serializer.deserialize(xreader); list = (list<asset>)obj;
i'm having same problem.
in msdn documentation specified:
note xmlserializer cannot deserialize following: arrays of arraylist , arrays of list.
but don't know if means cannot deserialize arrays of arraylist or arraylist... not clear me.
http://msdn.microsoft.com/en-us/library/dk9cbaf1%28v=vs.110%29.aspx
use service stack serializer :)
Comments
Post a Comment