I'm getting the content from a component and in this content I have a field that represents a keyword. How could I get the tcm from that keyword? "etiquetas" field is my keywords.

<destacado_evento xmlns="uuid:65081b19-5ae5-4e3e-a9d0-371ce48b0694">
    <titulo>Evento Skyfall</titulo>
    <imagen xlink:type="simple" xlink:href="tcm:12-3580" xlink:title="Multimedia Ficha Evento" xmlns:xlink="http://www.w3.org/1999/xlink" />
    <etiquetas>Nuestros compromisos</etiquetas>

The problem is that I don't know the category. I get that information from:

foreach (ItemFieldDefinitionData field in schema.Fields)
    XmlElement schemaFields = contenidoComponentes.CreateElement(field.Name);
    schemaFields.InnerText = field.Description;

2 Answers 2


If you load the Component with LoadFlags.KeywordXlinks, you will find that the XML elements representing Keyword field values get an xlink:href attribute which contains the Keyword ID (TCM URI or WebDAV URL depending on whether you also specify LoadFlags.WebDavUrls or not).

This is by far the cheapest way to get the Keyword IDs.

  • Hi Rick. Could you please show me an example of how it will be the code? Thanks in advance. May 21, 2016 at 8:24

If you have the title for the keyword and know the category attached to the component field, you can use below function to get the keyword id.

string GetKeywordId(string KeywordTitle, string categoryID)
    KeywordsFilterData kwdFilter = new KeywordsFilterData();

    var query1 = from XElement r1 in tridionClient.GetListXml(categoryID, kwdFilter).Descendants()
                 where r1.Attribute("Title").Value.ToLower() == KeywordTitle.ToLower()
                 select r1;
    XElement foundNode = query1.FirstOrDefault();
    if (foundNode != null)
           string keywordID = foundNode.Attribute("ID").Value;
           return keywordID;

    return "";
  • Hello Saurabh. What is a tridionClient? because if I use my CoreServiceClient object, I don't have in it a method called GetListXml. Thanks May 21, 2016 at 8:24

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.