When writing a special import tool for a Tridion 2011 project using the main service, I ran into a problem while trying to save the component.
The following code works fine when the field on the component matters, but when it fails, I get an error.
Here is my code (error handling removed for brevity):
var doc = new XmlDocument();
doc.LoadXml(component.Content);
var namespaces = new XmlNamespaceManager(doc.NameTable);
namespaces.AddNamespace("ns", doc.DocumentElement.NamespaceURI);
foreach (var field in componentFromSpreadsheet.Fields)
{
XmlNode xmlNode = doc.SelectSingleNode("//ns:" + field.Key, namespaces);
if (xmlNode == null)
{
xmlNode = doc.CreateNode(XmlNodeType.Element, field.Key,
doc.DocumentElement.NamespaceURI);
doc.DocumentElement.AppendChild(xmlNode);
}
string fieldValue = HtmlTidy.Tidy(field.Value);
xmlNode.InnerXml = fieldValue;
}
component.Content = doc.OuterXml;
client.Save(component, null);
Here is a post from Tridion:
"" 'uuid: 09ed2feb-f7cb-4760-ba4c-b9ff4f45d025' 'summary' 'uuid: 09ed2feb-f7cb-4760-ba4c-b9ff4f45d025'. : "related_links" 'UUID: 09ed2feb-f7cb-4760-ba4c-b9ff4f45d025
, .
, Xml. - ?