10

When working with the Core Service I am loading item XML that has Keywords inside and I need to replace some Keywords with others. Unfortunately the XML lists only the keyword name and not the tcm link to the Keyword item.

How can I get the Keyword object from the XML?

OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData
{
    ItemTypes = new[] { ItemType.Page }
};
filter.Recursive = true;

var pageXml = client.GetListXml(ConfigurationManager.AppSettings["SgTcmId"], filter);

//loop through each item and find out if it is the product we want
foreach (var pageElem in pageXml.Elements())
{
    string id = pageElem.Attribute("ID").Value;
    var pageData = (PageData)client.TryCheckOut(id, null);
    //...quick-and-dirty code for my eyes only...
}

1 Answer 1

13

Nuno had started this topic for Tom.net in another question: Getting additional keyword information from item Xml?. It's the same for Core Service.

Need to use LoadFlags as follows:

ReadOptions readOptions = new ReadOptions();
readOptions.LoadFlags = LoadFlags.KeywordXlinks;

...

var pageData = (PageData)client.TryCheckOut(id, readOptions);

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.