How to generate a complete XML script in a single variable from an Array in Make?

Hello everyone,

I have an Array Aggregator output that looks like this (simplified):

json

[
  { "ID PRESTA (J)": "370" },
  { "ID PRESTA (J)": "371" }
]

The number of “ID PRESTA (J)” is variable in my array.

My goal is to dynamically build the following XML script:

<cart_row>
  <id_product>370</id_product>
</cart_row>

<cart_row>
  <id_product>371</id_product>
</cart_row>

:blue_circle: Important:

  • I want the entire XML script inside a single variable (one big block of text).
  • I need it to be done in one operation only.

I tried using a map() and join() inside a Set Variable module but it didn’t work…
it either returns an empty result or an error, depending on my attempts.

:blue_circle: How should I correctly build the map() and join() expression to generate the full XML script in just one variable?

Thank you very much for your help!

Davy

Hi @Lash_MASTER
You can iterate the JSON and aggregate the results using the Text Aggregator.



Hi!

Thanks for your help!

In fact I have a deep structure of data and following your advice I iterated 3 times in order to extract the data I need, and then i simply used the text agregator and it works!

In source of the text agregator I used Iterator 58 and in the text field I used the clean data from iterator 59

I guess there are other more optimized solutions, I can t imagine it s so hard to manipulate


2 data from a vector. I can t wait to learn more, but for now as a beginner it’s ok for me.

Thanks again!

1 Like

@Lash_MASTER, can you share the full JSON? I’ll check if it’s possible to optimize the workflow using array functions.

1 Like