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
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.
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.
Please connect the DBInput source to the Talend tFileOutputXML. Within the Component, we have the following options.
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.
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.
Next, we used the EmployeesList as the Row tag. It means each row starts with this tag.
Let me run the Talend tFileOutputXML job to see whether we exported Database Table to XML File.
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.
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.
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.
Now, you can see three files whose name is Customers_XML (default we provided), and it added 0, 1, and 2.
Let me open the first file to show you the root tag (changed to Customers), and it has only five records.