Expand my Community achievements bar.

AEM 6.5 xml file generation with attributes of each element

Avatar

Level 1

Hello,  I earlier posted this same question at Adobe Support Community (AEM 6.5 xml file generation with attributes of eac... - Adobe Support Community - 14022424), but my message was LOCKED! We are a paying customer of adobe with licenses to Adobe Acrobat DC, Pro, Designer, etc. So not sure why I was locked, hence no one was able to answer the question.

 

Anyway, I am working on a dynamic form and using AEM 6.5 to build it. I have an export data button that when clicked, exports the data saved in the form to an xml with its corresponding elements. To be more precise, I have the following for exporting:

 

xfa.host.exportData("",0);

 

The generated xml file looks like the following. It has the elements tags and any value stored in the corresponding textfield, or checkbox, etc. 

 

<?xml version="1.0" encoding="UTF-8"?>
<root>

<ApplicationType>

<ATRadioButton100>1</ATRadioButton100>

<ATRadioButton050>1</ATRadioButton050>

<ADTextField170>345-908-7888</ADTextField170>

<ADTextField190>Engineer</ADTextField190>

..

..

 

What I would like to do is that when the xml is generated, it also includes an attribute for each element. For example:

 

<ADTextField170 name="phone">345-908-7888</ADTextField170>

 

Is it possible in AEM to set attributes for each object (e.g. textfield, radiobutton) that are then listed as part of the xml which is generated using the exportData function. If not, is there any other way to create an xml that contains data plus attribute(s) of each element. The reason being is that this way our clients will know what each element (textfield, radiobutton, checkbox, dropdown) variable is for by looking at its name attribute.  

 

Thank you in advance.

2 Replies

Avatar

Community Advisor

@shussai2 Recently I used the ROME API and org.w3c.dom package to convert a bunch of AEM pages into a RSS feed (essentially an xml output). These 2 APIs give you much more fine grained control over how you want your xml to look like.

for instance, adding page properties as xml attributes.

You can check and see if this fits your use case.

 

https://docs.oracle.com/javase/8/docs/api/index.html?org/w3c/dom/package-summary.html

https://rometools.github.io/rome/

 

Avatar

Level 1

Thank you so much for your reply. I did look at them, but I want to provide a button feature, where when a user presses "Export Data" in the pdf itself, it produces the xml with the elements, the client specific data, and each element attribute(s) that I have set in AEM when developing the form.

 

Even if its just one attribute, for example "name=SterilityField" instead of just the element STTextField12...

 

Is that possible from AEM to generate xml using xfa.host.exportData("",0) but it somehow contains the attribute as well.