table to xml

Hello, I have to generate an XML with the following structure:

image


root>  
 <products>
<product>
   <reference>PRODUCT 1</reference>
   <reference>PRODUCT 2</reference>
   <reference>PRODUCT 3</reference>
     </product>
  </products>
</root>

Where the PRODUCT 1, 2, etc. need to be replaced by the values from a table like this one:

image

I have been exploring the “Column to XML” and “String to XML” nodes, but I cannot find a way to achieve what I need. Does anyone have any ideas on how I can do this?

thanks!

Hi @Pablo

I’d say the Column to XML is the right way to go. You need a few of them since the conversion from the table to your desired xml, which is 4 levels deep, is quite a large one.

The trick here is to start at the lowest level, reference, and then work your way up. Output:
image

See WF:
table to xml.knwf (21.5 KB)

5 Likes

Thank you very much, ArjenEX.
With your explanation and your workflow, I have gained a better understanding of how to work with XML. Your solution is perfect.
I made some changes because if I have more than one model in the base table:

image

I needed to group them in the xml output like this:
image

by adding a loop to your workflow, I was able to resolve it.

I am attaching it in case it can be helpful to someone.

table to xml v2.knwf (16.0 KB)

Many thanks for your help!

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.