UML
How to serialise objects into XML, based on their UML class model.
UML, the Unified Modeling Language, is a standard way of seeing the design of a system. Class Diagrams describe the structure of a system by showing the system’s classes and how they relate to one another. A class definition comprises properties, methods and signals. Further classes may be associated with each other, or be attached to an association between other classes.
UML’s association classes can be considered the most general case.
<property-name object-id="ID" association-end-name-ref="IDREFS" >value</property-name>
Each property’s value is serialised into an element named for the property.
Multiple values become multiple elements.
A value may be a scalar data type, or a class type.
Object-ids may be ommitted for values which are non-referencable. (switchable)
If the object is an association, references to the IDs of the object are listed in attributes named for the association end.
Example
This simplified example shows that a reviewer writes a review of a reviewed item on a platform.

This could result in example serialisation as follows:
<reviewer id="id1"/> <reviewed id="id2"/> <platform id="id3"/> <review id="id4" reviewer="id1" reviewed="id2" platform="id3"> <rating>A</rating> <rating>B</rating> <review>A good product</review> </review>
The solid arrows from the diamond represent navigble owned ends
A reviewed object can navigate to the review link-object,
by adding an owned attribute property (the dot against the diamond):

This could result in example serialisation as follows:
<reviewer id="id1"/> <reviewed id="id2" review="id4"/> <platform id="id3"/> <review id="id4" reviewer="id1" reviewed="id2" platform="id3"> <rating>A</rating> <rating>B</rating> <review>A good product</review> </review>
whereby the reviewed object can navigate to the review, and thence to it’s platform and reviewer.
If you want direct navigation to the objects at the other end of association,
define a derived seriasable property. eg /reviewer = review.reviewer.
Whereas the review association end has a list of the review values linking the reviewer and platform, the derived /reviewer property omits the qualifying platform.
<reviewed id="id2" review="id4"> <reviewer ref="id1"/> </reviewed>
For the common special case of bilateral associations,
the derived property is as good as the indirect navigation via the link to the object.
Object Serialiasation vs Document Modelling
Note that this page described serialisation of general object models,
which retain the order of property values, but ignore the order of properties.
It does not describe the modelling of documents,
where the order of both the properties and their values is significant.
Document modelling can be acheived by stereotyping or inheriting classes as document elements, signifying that it has an explicit serialisation order of property values,
and may offer methods to edit this order. A mixed content signifier may allow text to be mixed with property values.