private static void SerializeTileObject(TileObject tileObject, XmlElement parentElement) { XmlDocument xmlDocument = parentElement.OwnerDocument; EntityType type = tileObject.GetEntityType(); if (xmlDocument != null) { XmlElement objectElement = xmlDocument.CreateElement("TileObject"); XmlAttribute typeAttribute = xmlDocument.CreateAttribute("Type"); string typePath = type.FullName; typeAttribute.Value = typePath; objectElement.Attributes.Append(typeAttribute); tileObject.AppendFields(objectElement); parentElement.AppendChild(objectElement); } else { throw new XmlHierarchyException("parentElement has no XmlDocument attached"); } }