I have been able to solve my problem using reflection.
Here is a code snippet that fills an XmlDocument (.NET) with the classnames of the tree:
internal void ReadFile(string filename)
{
object elm = syncAXISConfigSchema_InternalLib.ClassFactory.FromXmlFile(filename);
XmlDocument xmlDocument = new XmlDocument();
XmlElement element = xmlDocument.CreateElement(elm.GetType().Name);
xmlDocument.AppendChild(element);
ReflectData(elm, xmlDocument);
OnDataChanged(xmlDocument);
}
internal void ReflectData(object item, XmlDocument xmlDocument)
{
Type type = item.GetType();
foreach (PropertyInfo m in type.GetProperties())
{
if (m.PropertyType.Namespace == "cfg")
{
var element = xmlDocument.CreateElement(m.PropertyType.Name);
var node = xmlDocument.SelectSingleNode("*");
node.AppendChild(element);
object newItem = Activator.CreateInstance(m.PropertyType);
ReflectData(newItem, xmlDocument);
}
}
}