J
Johannes Elsinghorst
Hello,
I have a class "Version" and another two classes "SpezielleVersion1"
and "SpezielleVersion2", which inherit from "Version".
When i deserialize a xml-Instance of "SpezielleVersion1" like this:
XmlSerializer xs = new XmlSerializer(typeof(SpezielleVersion1));
XmlTextReader reader = new XmlTextReader(input);
return (SpezielleVersion1)xs.Deserialize(reader);
i get a proper object in return. But sometimes i dont want to
distinguish between
"SpezielleVersion1" and "SpezielleVersion2", instead i want to
deserialize them as a"Version":
XmlSerializer xs = new XmlSerializer(typeof(Version));
XmlTextReader reader = new XmlTextReader(input);
return (Version)xs.Deserialize(reader);
For that i annotated the "Version" class with
[XmlInclude(typeof(SpezielleVersion1),XmlInclude(typeof(SpezielleVersion2)]
Unfortunately the deserializer quits with an
IllegalArgumentException("<SpeziellVersion1 xmlns='http://...'> wasnt
expectedt.) when it reads "<zg:SpeziellVersion1... >" in the xml-file.
Does anybody have a clue why it does that?
thanks, Johannes Elsinghorst
I have a class "Version" and another two classes "SpezielleVersion1"
and "SpezielleVersion2", which inherit from "Version".
When i deserialize a xml-Instance of "SpezielleVersion1" like this:
XmlSerializer xs = new XmlSerializer(typeof(SpezielleVersion1));
XmlTextReader reader = new XmlTextReader(input);
return (SpezielleVersion1)xs.Deserialize(reader);
i get a proper object in return. But sometimes i dont want to
distinguish between
"SpezielleVersion1" and "SpezielleVersion2", instead i want to
deserialize them as a"Version":
XmlSerializer xs = new XmlSerializer(typeof(Version));
XmlTextReader reader = new XmlTextReader(input);
return (Version)xs.Deserialize(reader);
For that i annotated the "Version" class with
[XmlInclude(typeof(SpezielleVersion1),XmlInclude(typeof(SpezielleVersion2)]
Unfortunately the deserializer quits with an
IllegalArgumentException("<SpeziellVersion1 xmlns='http://...'> wasnt
expectedt.) when it reads "<zg:SpeziellVersion1... >" in the xml-file.
Does anybody have a clue why it does that?
thanks, Johannes Elsinghorst