Export Database Table to XML in Talend

In this section. We show you how to use tFileOutputXML to export database tables to XML in Talend with an example. For this Talend export db table to XML demo, we are using the SQL Database table, and the data inside this table is

Export Database Table to XML in Talend 0

Talend Export Database Table to XML File example

From the screenshot below, we can see that we established a Connection with SQL and then selected the Customer table using the DBInput.

Export Database Table to XML in Talend 1

Next, drag and drop the tFileOutputXML output field from the palette. As you can see from the tooltip, tFileOutputXML creates an XML structure from the input rows by broken down the rows into fields.

Export Database Table to XML in Talend 2

Please connect the DBInput source to the Talend tFileOutputXML. Within the Component, we have the following options.

Export Database Table to XML in Talend 3

Next, click the Edit Schema button to check the tFileOutputXML schema. Mostly, the input columns (DBInput) will sync with the tFileOutputXML. If that is not the case, close the schema window and click on the Sync columns button.

Export Database Table to XML in Talend 5

By default, the tFileOutputXML field selects the default location and out.xml as the file name. Please click the browse (…) button to select the existing file or create a new XML file. Here, we are creating the Customers_XML.xml in the Output files directory.

Export Database Table to XML in Talend 5

Next, we used the EmployeesList as the Row tag. It means each row starts with this tag.

Export Database Table to XML in Talend 6

Let me run the Talend tFileOutputXML job to see whether we exported Database Table to XML File.

Export Database Table to XML in Talend 7

You can see the XML file has all the customers, and each row starts with the EmployeesList tag. Here, we can change the root tag as well.

Export Database Table to XML in Talend 8

Please go to the Advanced Settings. It is the place where we can change the schema of the columns, and root tag default name, etc.

Export Database Table to XML in Talend 9

For the demo purpose, we added the Customers as the root tag. Next, we are splitting the input rows into multiple files where each file has a maximum of 5 records. It can do by simple check Split output in server files, and place the number for Rows in each output file option. Once you finish, click the Run button.

Export Database Table to XML in Talend 10

Now, you can see three files whose name is Customers_XML (default we provided), and it added 0, 1, and 2.

Export Database Table to XML in Talend 11

Let me open the first file to show you the root tag (changed to Customers), and it has only five records.

Export Database Table to XML in Talend 12