On a refactoring exercise we are working on, we have to change Page Templates for select websites. Most page get localized and have their page templates updated by the code below but for a few we get the following error:
XML validation error. Reason: The element 'Metadata' in namespace 'uuid:940d95aa-fcce-481c-8de5-c61d06c74f46' has invalid child element 'description' in namespace 'uuid:940d95aa-fcce-481c-8de5-c61d06c74f46'.
List of possible elements expected: 'TitleSEO, KeywordsSEO, DescriptionSEO, omniture' in namespace 'uuid:940d95aa-fcce-481c-8de5-c61d06c74f46'.
There is no description field in our metadata schema and TitleSEO, KeywordsSEO, DescriptionSEO, omniture are all optional fields which are not being changed by the code .
try
{
pData = client.Read(page.Attribute("ID").Value, null) as PageData;
//Localize Page
if (!(bool)pData.BluePrintInfo.IsLocalized)
{
client.Localize(pData.Id, new ReadOptions());
if (dTemplateIDs.ContainsKey(pData.PageTemplate.IdRef.ToString()))
{
pData.IsPageTemplateInherited = false;
pData.PageTemplate.IdRef = dTemplateIDs[pData.PageTemplate.IdRef];
client.Update(pData, new ReadOptions());
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error Inner " + ex.Message);
}