cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

XML Generator Arrays

alex_panganiban
Contributor

I'm having an issue with the XML Generator. I feel what I'm doing should work. Hoping someone can enlighten me on what's going on. I have an array that gets passed into the XML Generator snap. For each instance within the input array, I am attempting to get a single XML element with a value created, but instead, I'm getting back an entire object.

Here's my input:

alex_panganiban_0-1691709546654.png

Here's what I have coded in the XML Generator:

alex_panganiban_1-1691709622971.png

And here's the output I receive from the XML Generator.

alex_panganiban_2-1691709740820.png

What I expect and want to receive should look more like this:

 

     <b:guid>e139cd2c-b47c-4247-a25f-acb80122fa8b</b:guid>
</memberIds>
 
And eventually as I test with more data, it should look like this:
     <b:guid>e139cd2c-b47c-4247-a25f-acb80122fa8b</b:guid>
     <b:guid>x139cd2x-x47x-4247-x25x-xxx80122xx8x</b:guid>
     <b:guid>y139cd2y-y47y-4247-a25y-yyy80122yy8y/b:guid>
     <b:guid>z139cd2z-z47z-4247-z25z-zzz80122zz8z</b:guid>
</memberIds>
 
What am I doing wrong? My foreach looks good to me, but something is obviously off. Thanks in advance for the assist.
1 ACCEPTED SOLUTION

ivicakoteski
New Contributor III

Hi @alex_panganiban ,

You need to accesses to the memberId element of each object.

You can try with the following:

#foreach($memberIds in $members)
<b:guid>$memberIds.memberId</b:guid>
#end
 
BR.
Ivica

View solution in original post

2 REPLIES 2

ivicakoteski
New Contributor III

Hi @alex_panganiban ,

You need to accesses to the memberId element of each object.

You can try with the following:

#foreach($memberIds in $members)
<b:guid>$memberIds.memberId</b:guid>
#end
 
BR.
Ivica

alex_panganiban
Contributor

Awesome! Thanks Ivica. Your solution made me realize that the "memberIds" element does not actually need to exist in the incoming document. It's actually dynamic. Not knowing that was what was causing my problem. Thanks so much for this learning. My final solution was this:

 

#foreach($member in $members)
<b:guid>$member.memberId</b:guid>
#end