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.

Xpath expression to get multiple instances of a XML node in process

Avatar

Level 2

Hi,

I am creating a form with a section for adress. Multiple instances of the section can be added dynamically.

the xml corresponding to this section will be like

<address>

     <street></street>

     <city></city>

     <zip></zip>

</address>

When multiple instances of the adress section are added, multiple sets of <address> node will be present. When this form is submitted, I am trying to get the values of all the address sections and assign them to a list process variable like one list for street,one for city and so on.

I could not use any Xpath expression to fetch the values of all the instances. For example, xpath //address will return all the instances of adress nodes in the xml.. ./address//street will return all the instances of the street node. but when these xpath expressions were mapped to the process variable only the first instance of the node is returned. I tried with xpaths like address[*], but only one instance was returned. However when tried with appropriate index positions like address[1] or address[2] the corresponding address nodes are returned.

Can we use any xpath query to get multiple instances of a node in adobe LC process. If yes please help me with the expression. If there are altenate ways also, please suggest.

Thanks,

Muniyaraj

3 Replies

Avatar

Level 10

What I usually do is use the Count() xPath function to get the number of nodes and then implement a loop in my process with a counter to get each element(in your case address[i]).

Jasmin

Avatar

Level 2

How are you creating a loop in the process. Is it an additional task(e.g. executing a java program) in the process?(If so can u please explain in detail)

Is there no way to fetch the data using a single xpath expression?

Avatar

Former Community Member

Not sure if this helps, there is a section about creating loops in the Workbench ES2 Help at http://help.adobe.com/en_US/livecycle/9.0/workbenchHelp/000187.html#1032146. Another way would be to use a custom component as you suggest but you can do it in Workbench as well.

Hope that helps..

...Gil