all groups > dotnet xml > march 2007 >
You're in the

dotnet xml

group:

XML/SOAP Serilaiztion and Generic Collections


XML/SOAP Serilaiztion and Generic Collections DXRick
3/29/2007 3:34:04 PM
dotnet xml:
I have a class (UserAccount) that uses a List<T> to contain a collection of
Account classes. The Account class uses a List<T> to contain a collection of
the account items. If the Account class is a checking account its List<>
collection contains instances of the CheckItem class, which represents a
single register item in a checking account.

I would like to be able to use the three types of serialization on them. Of
course, the BinaryFormatter works fine. I tried to mark the List<> fields as
[SoapIgnore, XmlIgnore] and before XML or SOAP seriliazation create an Array
from it. However, the mere existence of the List<> class still causes XML
and SOAP seriliazation to fail, claiming that generics are not supported.

Is there a way I can use the generic List<> collection and still get XML and
SOAP serialization to work?

Thanks!
RE: XML/SOAP Serilaiztion and Generic Collections DXRick
3/30/2007 8:36:01 PM
Well, should I.....

1) Use an ArrayList instead?

2) Use a XMLWriter to create a XML version of the class's contents?

I do not intend to deserialize it, but rather to support XML and SOAP as
formats to export the data too.

Anyone????

TY
Re: XML/SOAP Serilaiztion and Generic Collections Joe Fawcett
3/31/2007 12:00:00 AM
There are two issues, firstly, as you say, the soap formatter cannot cope
with generics. Secondly you can still serialise to XML using XmlSerializer
directly.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

[quoted text, click to view]

AddThis Social Bookmark Button