Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Need to read xml/text file and populate it in Generic list page

Avatar

Level 2

ACS AEM common Generic list component provide us to list key/value pair on page. I have XML and flat files with tons of key/value pairs. Is there some way to directly populate all key/values from XML and text files to generic list.

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 10

Out of the box - there is no service. However - AEM is very powerful in that it lets you build custom services.

Create a custom AEM service that uses Java XML library to read XML:

http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/

You can also build Java logic to read from text fiile:

http://stackoverflow.com/questions/4716503/best-way-to-read-a-text-file

You can build this Java logic into a custom AEM Service:

https://helpx.adobe.com/experience-manager/using/first-osgi.html

The above article shows you how to build an AEM custom service. 

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Out of the box - there is no service. However - AEM is very powerful in that it lets you build custom services.

Create a custom AEM service that uses Java XML library to read XML:

http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/

You can also build Java logic to read from text fiile:

http://stackoverflow.com/questions/4716503/best-way-to-read-a-text-file

You can build this Java logic into a custom AEM Service:

https://helpx.adobe.com/experience-manager/using/first-osgi.html

The above article shows you how to build an AEM custom service. 

Avatar

Level 2

Is there any example to add new child node through sling API calls?

I am able to manage below code snippets through some research but somehow it doesn't work  

String file = "/etc/acs-commons/lists/test/jcr:content/list";

       Resource pageResource = rr.getResource(file);        
        Map<String,Object> prop =  new HashMap<>();
        prop.put("jcr:title","test");
        prop.put("value","testvalue");
        Resource newr = rr.create(pageResource,"item3",prop);

Thanks,

Avatar

Level 2

Never mind, I got it working now.

I didnt close and commit resource resolver - that did trick.