I have done a program in Java which sets ItemTypes in Tridion and gets the list of all specified ItemTypes in a Publication. I have used Element to getList of items.

import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.sdltridion.contentmanager.coreservice.ICoreService;
import com.sdltridion.contentmanager.coreservice.ICoreServiceGetListXmlCoreServiceFaultFaultFaultMessage;
import com.sdltridion.contentmanager.coreservice.ICoreServiceGetSystemWideListXmlCoreServiceFaultFaultFaultMessage;
import com.sdltridion.contentmanager.r6.ArrayOfItemType;
import com.sdltridion.contentmanager.r6.ItemType;
import com.sdltridion.contentmanager.r6.ListBaseColumns;
import com.sdltridion.contentmanager.r6.ObjectFactory;
import com.sdltridion.contentmanager.r6.RepositoryItemsFilterData;

public class RepositoryItemsFilterDataDemo {

   public static void getRepositoryItems(ICoreService endpoint) throws ICoreServiceGetListXmlCoreServiceFaultFaultFaultMessage
      ObjectFactory objectFactory = new ObjectFactory();
      ArrayOfItemType itemTypes = objectFactory.createArrayOfItemType();

      RepositoryItemsFilterData filter = objectFactory.createRepositoryItemsFilterData();

      ListBaseColumns baseColumns = ListBaseColumns.EXTENDED;


      Element element = (Element) endpoint.getListXml("tcm:0-29-1", filter).getAny();

      NodeList schemaList =element.getElementsByTagName("tcm:Item");

      for (int i = 0; i < schemaList.getLength(); i++) {
         Element itemXml = (Element) schemaList.item(i);

         StringBuffer sb = new StringBuffer();
         sb.append("<tcm:Item" + " ");
         sb.append("ID = " );
         sb.append(" " + "Title = " );
         sb.append(" " + "Type = " );
         sb.append(" " + "Modified = " );
         sb.append(" " + "FromPub = " );
         sb.append(" " + "Icon = " );

When I debug my program the element object is returning null. But when I run the program the output is displayed as


[tcm:ListItems: null]
<tcm:Item ID = tcm:29-2643-4 Title = 000 Effective treatment of .... Type = 4 Modified = 2013-01-31T01:35:17 FromPub = 040 Merck Connect Website Icon = T4L0P1/>

Can any one suggest what might cause this problem and also can any one suggest how can I get the output in XML format like the one in .NET without hard coding the xml format.

.NET output :

<tcm:ListOrganizationalItems xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
    <tcm:Item ID="tcm:29-107-4" ParentOrgItemID="tcm:0-29-1" Title="Root" Type="4" Modified="2012-09-14T11:06:07" FromPub="000 WCM Empty Parent" Icon="T4L0P1"/>
  • the output is exactly as you specify it, but take a look at stackoverflow.com/questions/1219596/… that shows a way of serializing XML Elements. Apr 19, 2013 at 13:26
  • Hello, I am new to Tridion and have just seen you question. can you please tell me where can I download the jar file for integration with Tridion? I am writing a java client that ineracts with Tridion core services? Thanks
    – p.p
    Apr 30, 2013 at 16:34
  • @user2197873 I've added my comment as an answer since you indicated it was useful, could you accept it if you still agree with that comment so we can finalize this question with a fitting answer? May 15, 2013 at 11:25
  • @adi check out yatb.mitza.net/2013/04/a-java-core-service-client-for-sdl.html there is a jar file available for you there. May 15, 2013 at 15:53

1 Answer 1


To give this question an answer for future references, I'll post the information from my reference given in my comment.

The result of the getListXml method is available as a org.w3c.dom.Element, by serializing that, it can be outputted as a string. https://stackoverflow.com/questions/1219596/how-to-i-output-org-w3c-dom-element-to-string-format-in-java shows several ways of how this can be done. Assuming you want to stick with the standard Java APIs, you can use a DOMImplementationLS:

Document document = node.getOwnerDocument();
DOMImplementationLS domImplLS = (DOMImplementationLS) document.getImplementation();
LSSerializer serializer = domImplLS.createLSSerializer();
String str = serializer.writeToString(node);

If the <?xml version="1.0" encoding="UTF-16"?> declaration bothers you, you can use a transformer instead:

TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer();
StringWriter buffer = new StringWriter();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.transform(new DOMSource(node), new StreamResult(buffer));
String str = buffer.toString();

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.