471,325 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

inheritance vs xml

Hello!

I have inheritance between classes which are the result of xml
serialization.
My question is how can I insure in serializaion stage that the hierarchy
in xml is according to inheritance hierarchy in classes?

Thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
5 959
On May 12, 9:54*am, csharpula csharp <csharp...@yahoo.comwrote:
Hello!

I have inheritance between classes which are the result of xml
serialization.
My question is how can I insure in serializaion stage that the hierarchy
in xml is according to inheritance hierarchy in classes?

Thank you very much!

*** Sent via Developersdexhttp://www.developersdex.com***
Hi,

Can you give more details? it;s not very clear where is your problem.
Jun 27 '08 #2
Hi,

E.g. try to deserialize the class tree, then validate the result.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

ccHello!
cc>
ccI have inheritance between classes which are the result of xml
ccserialization.
ccMy question is how can I insure in serializaion stage that the
cchierarchy
ccin xml is according to inheritance hierarchy in classes?
ccThank you very much!
cc>
cc*** Sent via Developersdex http://www.developersdex.com ***
cc>
Jun 27 '08 #3

My question is : if I have ClassA:ClassB and in xml Class B element has
a memeber which is not of type A or B - is there an error in loading
this xml?
*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4
My question is : if I have ClassA:ClassB and in xml Class B element has
a memeber which is not of type A or B - is there an error in loading
this xml?
See XmlAnyAttributeAttribute / XmlAnyElementAttribute:

http://msdn.microsoft.com/en-us/libr...attribute.aspx
http://msdn.microsoft.com/en-us/libr...attribute.aspx

Marc
Jun 27 '08 #5
Also - it suggests no error is raised by default, but you can detect
unknown nodes and do what you want:

http://msdn.microsoft.com/en-us/libr...knownnode.aspx

"By default, after calling the Deserialize method, the XmlSerializer
ignores XML nodes of unknown types. However, you can use this event to
handle such node types."

http://msdn.microsoft.com/en-us/libr...attribute.aspx

"By default, after calling the Deserialize method, the XmlSerializer
ignores XML attributes of unknown types. However, you can use this event
to handle such node types."

Marc
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Graham Banks | last post: by
4 posts views Thread by JKop | last post: by
5 posts views Thread by Morgan Cheng | last post: by
10 posts views Thread by davidrubin | last post: by
14 posts views Thread by Steve Jorgensen | last post: by
22 posts views Thread by Matthew Louden | last post: by
45 posts views Thread by Ben Blank | last post: by
6 posts views Thread by Bart Simpson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.