public XmlNode ToXml(XmlDocument xmlDocument) { XmlNode topicXml = xmlDocument.CreateElement("topic"); topicXml.AppendChild(umbraco.xmlHelper.addTextNode(xmlDocument, "title", Title)); topicXml.AppendChild(umbraco.xmlHelper.addCDataNode(xmlDocument, "body", Body)); topicXml.AppendChild(umbraco.xmlHelper.addTextNode(xmlDocument, "urlname", UrlName)); // tags XmlNode tags = umbraco.xmlHelper.addTextNode(xmlDocument, "tags", ""); foreach (var tag in Tags) { var tagNode = umbraco.xmlHelper.addTextNode(xmlDocument, "tag", tag.Name); tagNode.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "id", tag.Id.ToString())); tagNode.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "weight", tag.Weight.ToString())); tags.AppendChild(tagNode); tags.AppendChild(tagNode); } topicXml.AppendChild(tags); if (topicXml.Attributes != null) { topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "id", Id.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "parentId", ParentId.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "memberId", MemberId.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "latestReplyAuthor", LatestReplyAuthor.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "created", Created.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "updated", Updated.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "locked", Locked.ToString())); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "replies", Replies.ToString(CultureInfo.InvariantCulture))); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "answer", Answer.ToString())); topicXml.Attributes.Append(umbraco.xmlHelper.addAttribute(xmlDocument, "score", Score.ToString())); } return(topicXml); }