EDN Admin
Well-known member
Heya guys, quick question:
I just started working with XML and XML schemas. I have an XML schema (that I didnt write) that I generate classes for using XSD.exe. I then want to use those classes, along with XMLSerializer to easily read and write XML that fits the schema.
There are several different classes in the generated schema classes, and so I want an XMLSerializer that knows about all of them.
However, when I try to create a new XMLSerializer using the (Type, Type[]) constructor, Im hitting an exception about anonymous types in the the extraTypes[] array I pass. However, it seems perfectly valid for the root "Type" to be anonymous.
Why is it valid to have the root type be anonymous, but not any additional type?
It seems like the best solution available to me is to create a number of XMLSerializers, one for each type, and then choose the XMLSerializer to use based on manually parsing the current node type. Is this the best way to handle it?
Thanks,
-Chris
View the full article
I just started working with XML and XML schemas. I have an XML schema (that I didnt write) that I generate classes for using XSD.exe. I then want to use those classes, along with XMLSerializer to easily read and write XML that fits the schema.
There are several different classes in the generated schema classes, and so I want an XMLSerializer that knows about all of them.
However, when I try to create a new XMLSerializer using the (Type, Type[]) constructor, Im hitting an exception about anonymous types in the the extraTypes[] array I pass. However, it seems perfectly valid for the root "Type" to be anonymous.
Why is it valid to have the root type be anonymous, but not any additional type?
It seems like the best solution available to me is to create a number of XMLSerializers, one for each type, and then choose the XMLSerializer to use based on manually parsing the current node type. Is this the best way to handle it?
Thanks,
-Chris
View the full article