How to Fetch ChildKeywords from ParentKeyword

In General we have might come across getting all Keywords from a taxonomy using the broker Query but in one of the recent project there is a situation that need to get the list of Child Keywords from the Parent Keyword doing doing the Search Query.

Tried Several but couldn't get but finally succeeded in getting those child elements, so just wanna share this simple Logic to so that it will useful in near future

It's the same way you pass the Taxonomy you need to pass the parentKeyword: "tcm:xx-xxxx-1024"

TaxonomyFactory factory = new TaxonomyFactory();

Keyword rootKeyword = factory.GetTaxonomyKeyword(parentKeyword);

rootKeyword = factory.GetTaxonomyKeywords(rootKeyword.TaxonomyUri,
new CompositeFilter(), parentKeyword, new Keyword[] { });

if (rootKeyword.KeywordChildren.Count > 0)
{
   foreach (Keyword item in rootKeyword.KeywordChildren)
   {
     // Good to implement your Logic
   }
}

Anonymous