I am trying to create Components using Tridion Core Service. I want to insert raw HTML content on Source tab of Rich Text Field. Refer the attached screenshot which manually I modified, the same thing I want using Core Service -
Using normal content I can able to create the components. But while I am providing HTML content, then I am getting error.
Could someone please help me!!. Thanks in advance.
I am using the below code -
public string HandleXhtmlFieldDefinitionData(ItemFieldDefinitionData field, DataRow row, StringBuilder sb)
{
string field_Name = string.Empty;
string field_Value = string.Empty;
field_Name = field.Name;
field_Value = row[field_Name].ToString();
string[] field_Values = field_Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string value in field_Values)
{
sb.Append("<" + field_Name + ">" + value.Trim() + "</" + field_Name + ">");
}
return sb.ToString();
}
While I am providing the normal content then I am getting no error. But while I am providing HTML snippet then I am getting the below error -
XML validation error. Reason: The element 'description' in namespace 'uuid:bdeed3aa-7a94-493d-962c-128505e6022e' has invalid child element 'div' in namespace 'uuid:bdeed3aa-7a94-493d-962c-128505e6022e'. List of possible elements expected: any element in namespace 'http://www.w3.org/1999/xhtml'.