Tuesday 15 March 2011

c# - Maintaining xml hierarchy (ie parent-child) information in objects generated by XmlSerializer -


For some time now I am trying to solve the following problem and I am starting to run away from ideas:

I have prepared a set of C # classes using Xsd.exe tool from XSD schema and dysfunctioning xmi files works fine. The problem is that besides the convenience and security of using auto-generated classes, I need information about the XML hierarchy, that is, I need to establish parental relationships between objects created during deserialization. Note that I want to avoid keeping a separate XML hierarchy structure (like a DOM tree), but keep track of the generated objects to keep track of your parents and children.

I have been able to shut it down in JAXB:

  1. Define a common base class for all deserialized objects in this base class And the reference to the guardian object (if any) are included.

  2. Using Unmarshaller. Listener Functionality Provides Callback on Full Object Deserialization This callback recently provides a reference to the parents of the deserialized object, which establishes maligning the parent's relationships.

How do I do this in C #? I have taken a look at the MSDN docs and made many goalkeepers, but there is no useful information available.

I wrote about this article some time ago, maybe it can help you.


No comments:

Post a Comment