using System.Xml; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls { /// /// Overrides the object to return the value as XML. /// public class XmlData : umbraco.cms.businesslogic.datatype.DefaultData { /// /// Initializes a new instance of the class. /// /// Type of the data. public XmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType) : base(dataType) { } /// /// Converts the data value to XML. /// /// The data to convert to XML. /// public override XmlNode ToXMl(XmlDocument data) { // check that the value isn't null and starts with an opening angle-bracket. if (this.Value != null && xmlHelper.CouldItBeXml(this.Value.ToString())) { // load the value into an XML document. var xd = new XmlDocument(); xd.LoadXml(this.Value.ToString()); // return the XML node. return data.ImportNode(xd.DocumentElement, true); } else { // otherwise render the value as default (in CDATA) return base.ToXMl(data); } } } }