I have tried the following code to get xml.
void getListXml(ICoreService endpoint, String myUri) throws Exception {
TaxonomiesFilterData filter = new TaxonomiesFilterData();
Element listXml = (Element) endpoint.getListXml(myUri, filter).getAny();
NodeList items = listXml.getElementsByTagName("tcm:Item");
System.out.println("xml element is : " + listXml);
for (int i = 0; i < items.getLength(); i++) {
Element itemXml = (Element) items.item(i);
System.out.println(itemXml.getAttribute("Title"));
}
}
but i am getting error with message
com.sdltridion.contentmanager.coreservice.ICoreServiceGetListXmlCoreServiceFaultFaultFaultMessage: Unexpected item type: Category.
it would be helpful if get some input on this.
EDIT : I have Changed the implementation to TaxonomiesOwlFilter
TaxonomiesOwlFilterData taxonomyFilter = new TaxonomiesOwlFilterData();
ArrayOfLinkToCategoryData arrayOfLinkToCategoryData = new ArrayOfLinkToCategoryData(){
@Override
public List<LinkToCategoryData> getLinkToCategoryData() {
List<LinkToCategoryData> linkToCategoryDatas = new ArrayList<>();
LinkToCategoryData linkToCategoryData = new LinkToCategoryData();
linkToCategoryData.setIdRef(new JAXBElement<String>(new QName("http://www.sdltridion.com/ContentManager/R6","IdRef"), String.class, categoryId));
return linkToCategoryDatas;
}
};
taxonomyFilter.setRootCategories(new JAXBElement<ArrayOfLinkToCategoryData>(new QName("http://www.sdltridion.com/ContentManager/R6","RootCategories"),ArrayOfLinkToCategoryData.class,arrayOfLinkToCategoryData));
GetListXmlResult getListXmlResult = endpoint.getListXml(publicationId, taxonomyFilter);
System.out.println(getListXmlResult.getAny());
then i am getting output as :
[rdf:RDF: null]
getListXmlResult.getAny()
represents an XML element (the root element of the OWL). Not sure whatSystem.out.println
does with an XML element as input, but it seems to output the tag name, which seems correct.