Another way to work with XML data structures from game objects and properties is by serializing the content of an object automatically. This technique automatically generates XML for all the public properties of an object. This recipe uses the XmlSerializer class that can be found in the standard System.Xml C# package.
This recipe has been adapted from this 2013 (still works!) Unify Community Wiki article: http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer