This is just a simple case of serialization. Having worked on 10+ game engines and other scene graph based applications I would prefer a more flexible reference based approach.<p>Instead of hard coding your hierarchy into the structure of XML or JSON. Define some basic type information (unique id and node type).<p>If you have situations where an object can be referenced before it is defined simply make a proxy loading type that listens for it to load.<p>After that it is a cakewalk:<p>[<p>{<p><pre><code> id: "UUID OR Rolling Number Per File OR DB Index OR ...",
type: "business",
name: "Dunder Mifflin Paper Company, Inc."
description: "look at me I can be a root type for the graph OR one of many!"
offices: [
list of ids of objects of type "office" or object that wraps this with other metadata (relation object)
]
},
... potentially other business entries,
{
id: see above...
type: "office",
name: "Scranton Branch",
description: "This can describe each branch"
departments: [
list of ids of objects of type "department" or object that wraps this with other metadata
]
},
... other offices,
{
id: see above...,
type: "department",
name: "sales",
members: [
list of ids of objects of type "employee" or object that wraps this with other metadata
]
},
... other departments,
{
id: see above...,
type: "employee",
title: "manager",
name: "Michael Scott",
reports: [
list of ids of objects of type "employee" or object that wraps this with other metadata
]
},
{
id: see above...,
type: "employee",
title: "sales man",
name: "Dwight Schrute",
reports: [
id of self since Dwight needs someone he can trust,
{
id: see above...,
type: "report_meta",
reportee: id of Pam,
visibility: "secret"
}
]
},
... other employees,
etc.,
etc.
]</code></pre>