Five Stars

Recordset to XML

I have a table with some data in it, for example: 

 

ID Name Type

1ProductATypeA
2ProductBTypeA
3ProductCTypeB

 

 I am willing to get the next XML 

 

 

<Products>
<Product>
<ID>1</ID>
<Name>ProductA</Name>
<Type>TypeA</Type>
</Product>
<Product>
<ID>2</ID>
<Name>ProductB</Name>
<Type>TypeA</Type>
</Product>
<Product>
<ID>3</ID>
<Name>ProductC</Name>
<Type>TypeB</Type>
</Product>
</Products>

 

 

What I am getting is the next

 

 

<Products>
<Product>
<ID>1</ID>
<Name>ProductA</Name>
<Type>TypeA</Type>
</Product>
</Products>

 

My current flow is the next

 

tMSSqlSp -> tParseRecordSet -> tMap -> tWriteXMLField

First I execute the procedure to get my results, I parse them to fields using the tParseRecordSet, I use a tMap to generate XML out of the parsed results and then I use the tWriteXMLField to try to complete my XML. Products is a group element whereby I have choosen the Product as a loop. I might be misunderstanding how the loop functionality works, as I am only getting the first result as a XML. 

 

We are entitled to Talend ESB version 6.1.1 and have an enterprise license. 

 

For your information, I of course used fictional data as it is company sensitive. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Fifteen Stars

Re: Recordset to XML

You need to look at this https://help.talend.com/reader/ixBASPZJ7IvqUQVupZwWbg/EFuE5Nul595D24TRwbFnbw

 

Pay special attention to the "All in One" boolean on your tXMLMap output. This will need to be set to true.

Rilhia Solutions
Fifteen Stars

Re: Recordset to XML

It doesn't need to start from an XML....that is just the example. It can start from row data. In fact most people use it that way. Here is a somewhat more complicated tutorial on how to use the tXMLMap. Ignore the Java code as that is for something else, but look for where I explain the tXMLMap settings

https://www.rilhia.com/tutorials/load-xml-files-batches-records

Rilhia Solutions
6 REPLIES
Fifteen Stars

Re: Recordset to XML

You need to look at this https://help.talend.com/reader/ixBASPZJ7IvqUQVupZwWbg/EFuE5Nul595D24TRwbFnbw

 

Pay special attention to the "All in One" boolean on your tXMLMap output. This will need to be set to true.

Rilhia Solutions
Nine Stars

Re: Recordset to XML

Are you looking for the following output?

 

testxml.PNGtestxml1.PNG

Regards,

Veeru Boppudi
Five Stars

Re: Recordset to XML

I already have seen the example and it is not entirely the same though. It already starts from a XML, where I start from a RecordSet. I have the following columns, all on the same level:

 

  • ID
  • Name
  • Type

From my understanding, as I am only a rookie using Talend, the tMap gets executed for each record in the recordset, which then has to be combined into a new XML by using the tWriteXMLField. 

 

Neither do I have the option "All in One". 

Five Stars

Re: Recordset to XML

Yes, that's it vboppudi. Except I don't want it to be written to a file as it has to be stored in the body to return to a route. Unless it's a requirement?
Fifteen Stars

Re: Recordset to XML

It doesn't need to start from an XML....that is just the example. It can start from row data. In fact most people use it that way. Here is a somewhat more complicated tutorial on how to use the tXMLMap. Ignore the Java code as that is for something else, but look for where I explain the tXMLMap settings

https://www.rilhia.com/tutorials/load-xml-files-batches-records

Rilhia Solutions
Eleven Stars

Re: Recordset to XML

@KennethA,are you looking for this?

Untitled.pngUntitled.pngUntitled.png

Manohar B