Tridion2013. Can someone provide example of core service code retrieving list of metadata fields of a component from multiple folders. Instead of hardcoding the metadata field name, I would like to retrieve all metadata fields from the component.


2 Answers 2


So now you got the metadata xml of the component, the Tridion core service role is over; it's all about compiling the xml and get the desired things out of it using .net.

So assuming you want to get the values of metadata fields, you can follow the below example code, I haven't run it though so you may need some adjustments as well.

doc = XDocument.Parse(component.Metadata);
xmlData = doc.Root;
var elements= xmlData.Descendants();
 foreach (XElement element in elements)
   //get the value using element.Value

There are many core service code examples available in the Tridion Practice Cookbook. You can browse through them here: https://github.com/TridionPractice/tridion-practice?files=1

There are also many online blogs and q&a here with code samples too. Have a browse through, and if you still are stuck, let us know what exactly it is you're stuck on and we'd be happy to help.

  • thanks for the help. I got some progress and getting component data correctly but metadata fields are coming as below.. <Metadata xmlns=\"23232322323232\"> <a>Text-A</a> <a>Text-A</a> <c>Text-C</c> <d>Text-D</d> <e>Text-E</e> <e>Text-E</e> <g>Text-G</g> <h>Text-H</h> <i>Text-i</i> <j>1999-02-01</j> <k>2015-07-30</k> </Metadata> few elements are duplicate (e.g. <a>) in this. not sure how to get these values. I got the metadata values by XElement xMetaData = XElement.Parse(component.Metadata); I need to put the values in proper format.
    – San
    May 4, 2016 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.