I'm using the code below to loop through CTs. I want to get the XML in the source tab. I can see it in the node if I look at the full XML block for the CT, but how can I get it from the ComponentTemplateData object? Do I need to call GetListXML instead?

var ro = new ReadOptions();
String[] pubs = new String[]{"tcm:0-1-1"};
foreach(String s in pubs){  
var pub = Tridion.Read(s, ro);
//Component Templates
filter.ItemTypes = new ItemType[]{ItemType.ComponentTemplate};
var list = Tridion.GetList(s, filter);

foreach(var item in list){


You can use componenttemplatedataobject.Content to get the xml as in the source tab. In your example if you use ctb.Content it will give you the xml as in the source tab

| improve this answer | |
  • 1
    The Content property is already a string, so no need for a .ToString() on it – David Forster Jul 23 '15 at 7:56
  • 1
    Not sure if Content comes prepopulated from a GetList() call; you might need ctb = (ComponentTemplateData)Tridion.Read(ctb.Id, ro) – Bjørn van Dommelen Jul 23 '15 at 11:31
  • @DavidForster removed it – Vipin Kothari Jul 23 '15 at 11:39
  • @BjørnvanDommelen Correct. The content won't be loaded from the GetList call's IdentifiableObjects – David Forster Jul 23 '15 at 11:57
  • Thanks! That worked. So GetList() returns IdentifiableObjects, which just contains some basic descriptive info and read returns the specific object. – Mr Smith Jul 23 '15 at 13:16

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.