using System; using System.Xml; using System.Xml.Linq; using Umbraco.Core.Configuration; namespace Umbraco.Core.Models { public static class PropertyExtensions { /// /// Creates the xml representation for the object /// /// to generate xml for /// Xml of the property and its value public static XElement ToXml(this Property property) { string nodeName = UmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias(); var xd = new XmlDocument(); XmlNode xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, ""); //This seems to fail during testing xmlNode.AppendChild(property.PropertyType.DataType(property.Id).Data.ToXMl(xd)); var element = xmlNode.GetXElement(); return element; } } }