How to create XML document from nested objects?
问题 I'd like to created an xml document with nested elements from an object with nested objects but the xml file comes out too flat. How can I get this to iterate the objects within objects to create elements within elements. public object traverse(object pc, string xpath, XmlDocument xmldoc) { IEnumerable enumerable = pc as IEnumerable; if (enumerable != null) { foreach (object element in enumerable) { RecurseObject ro = new RecurseObject(); ro.traverse(elementArray, xpath, xmldoc); } } else {