I'm currently working on the process of importing specific elements of legacy Tridion data (held within R5) into Tridion 2013 via the Core Service, and I've got a simple test pretty much up and running. I can create the components and get the data that I've extracted from R5 in there as I need to, however I'm encountering issues when dealing with Rich Text Fields - Tridion is encoding the HTML tags within the content I'm passing through.
So content like this:
<p>While this beautiful parc has a tranquil atmosphere, it also offers you plenty to do. A giant wave pool and an 18 hole golf course are just two of the attractions.</p>
becomes:
<p>While this beautiful parc has a tranquil atmosphere, it also offers you plenty to do. A giant wave pool and an 18 hole golf course are just two of the attractions.</p>
As a result of this, the data isn't ending up in the component in a usable format. Editors would have to go in and manually correct the data, which kind of defeats the point of the import process!
I've tried inserting it as CData and also as a string validated through Tidy.NET (which I found as a suggestion here: http://nunolinhares.blogspot.co.uk/2011/06/importing-content-into-tridion.html), but I get the same behaviour no matter what I do. I can inspect the component object that I'm passing to the CoreService and know from that that the HTML is unencoded when it's passed through - so there must be something on the Tridion end that's playing with it.
Would anyone know whether I'm missing something, or whether something specific needs to be done in order to stop Tridion from encoding the data passed to it - so that I can get the paragraph markup inserted directly into the Source of the RTF "as is"? The code I'm using follows:
Tridion.ComponentData component;
component = client.GetDefaultData(Tridion.ItemType.Component, "tcm:20-104-2", null) as Tridion.ComponentData;
component.Title = "testimport component";
component.Id = "tcm:0-0-0";
component.Content = newSite.Serialize();
component.Schema.IdRef = "tcm:20-606-8";
try
{
client.Create(component, null);
phResult.Controls.Add(new LiteralControl("Successfully created component!"));
}
catch (Exception ex)
{
phResult.Controls.Add(new LiteralControl("Error: " + ex.ToString()));
}
Any help would be very much appreciated!
newsite
for an object and do you actually need to call.Serialize()
on it?newsite.Serialize()
returns the encoded HTML already, while it should just be theOuterXml
ofXmlDocument.DocumentElement
with XHTML as child elements for the RTF field.