Need to read xml/text file and populate it in Generic list page | Community
Skip to main content
New Participant
October 16, 2015
Solved

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

  • October 16, 2015
  • 5 replies
  • 2823 views

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,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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. 

5 replies

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

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. 

New Participant
October 16, 2015

Thanks Scott! Let me try it.

New Participant
October 16, 2015

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,

New Participant
October 16, 2015

Never mind, I got it working now.

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

smacdonald2008
New Participant
October 16, 2015

Good job!!