enter image description hereenter image description hereI want to update the data inside the rich text field, however on updation the data is filled into the "Design" tab of the richtext field, instead of the "Source" tab due to which the format of data is gettting spoilt. Below is the code I am using to update the fields :

 cdo = (ComponentData)_client.TryCheckOut(tcmId, null);
                        if (cdo.IsEditable.Value)
                            XElement xmlData;
                            XDocument doc;
                            doc = XDocument.Parse(cdo.Content);
                            xmlData = doc.Root;
                            var ns3 = xmlData.GetDefaultNamespace();
if (xmlData.Descendants(ns3 + "fieldname").Any())
                            xmlData.Descendants(ns3 + "fieldname").SingleOrDefault().Value = ShortdescRAW;
                            cdo.Content = doc.ToString();
                        _client.Update(cdo, null);

Which is displaying data as in the image], instead of as as a bullet list of items. Can someone please guide as to how can I insert data into the "source" tab instea dof the design field?

  • seems you are storing the escaped tags or strings values instead of XML content string, please edit your question to update your code how you loading and preparing the content value in doc variable before assigning to cdo.Content= doc.ToString();
    – Velmurugan
    Commented May 16, 2019 at 12:31
  • I have edited the code
    – M.S
    Commented May 16, 2019 at 13:26
  • Can you try cdo.Content = doc.Root.CreateNavigator().OuterXml;
    – Velmurugan
    Commented May 16, 2019 at 14:16
  • Can you please edit your question and update the source tab XML screenshot? And also update what is the value of this variable ShortdescRAW?
    – Velmurugan
    Commented May 16, 2019 at 14:18
  • ShortdescRAW has value that is getting printed in the "Design" field of the rich text with all the HTML tags . Also, the CreateNavigator function doesn't seem to work for Xdoc .
    – M.S
    Commented May 16, 2019 at 15:00

2 Answers 2


In these kinds of situations when I don't know what Tridion expects from me, ie. various namespaces, escaped/non-escaped content, etc., what I usually do is create a Component manually and fill out the data I need, in this case the source tab of the RTF. Then I read that component via Core Service and examine the Content property. Once you have that, you can reverse engineer what the content needs to be for a new Component.


For these sort of operations, I would recommened to use Fields class from the Tridion practice wiki: https://github.com/TridionPractice/tridion-practice/tree/74f53c5b611347d09100be12c644566488974b80/ChangeContentOrMetadata

To manipulate RTF data you could load it into a XmlDocument for parsing it.

For example:

        var component = (ComponentData)client.Read(tcmuri, DEFAULT_READ_OPTIONS);
        var fields= Fields.ForContentOf(schemaFields, component);
        var inputRtfValue = fields["rtfFieldName"].value;
        string manipulatedRtfData = ManipulateRtfData(inputRtfValue);

        fields["richTextField"].Value = manipulatedRtfData;
        component .Content = fields.ToString();

        client.CheckOut(component.Id, true, DEFAULT_READ_OPTIONS);                       
        client.Save(component, DEFAULT_READ_OPTIONS);
        client.CheckIn(component.Id, DEFAULT_READ_OPTIONS);

 public string ManipulateRtfData(string xhtmlFieldValue) 
        // decalre required namespaces
        string XlinkNamespace = "http://www.w3.org/1999/xlink";
        string XhtmlNamespace = "http://www.w3.org/1999/xhtml";
        string TcmtNamespace = "http://www.tridion.com/ContentManager/5.2/Taxonomies#";
        string XlinkPrefix = "xlink";
        string XhtmlPrefix = "xhtml";
        string TcmPrefix = "http://www.tridion.com/ContentManager/5.0";

        XmlDocument XmlContent = new XmlDocument();
        XmlNamespaceManager nm = new XmlNamespaceManager(new NameTable());
        nm.AddNamespace(XlinkPrefix, XlinkNamespace);
        nm.AddNamespace(XhtmlPrefix, XhtmlNamespace);
        nm.AddNamespace(TcmPrefix, TcmtNamespace);

        XmlContent.LoadXml("<root>" + xhtmlFieldValue + "</root>");
        // manipulate Xml document here (rtf data)

         return XmlContent["root"].InnerXml;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.