XML is the eXtensible Markup Language and is both human and machine-readable. XML is a form of Electronic Data Interchange.
Here, let us create a new input file definition in our Metadata Repository. The data is both simple and useful, so provides a good real-world use for some XML content.
MindMajix Talend Training course is designed to make you an expert in developing ETL solutions using the Talend platform. Start Learning! |
The following shows a few entries from the Wikipedia Abstract Database. These files are large. You will find it helpful to create your own small sample file or to use the data shown below.
Open the New XML File dialog, by selecting Metadata->File XML and then selecting Create file xml by activating the popup menu (mouse right-click).
For this tutorial, set Name to WikipediaAbstract and press Next.
Select the specification model. This may be either Input XML or an Output XML. For this tutorial, we are creating an Input XML model. Hit the Next button to proceed.
Related Article: Talend Interview Questions & Answers |
Hit the Browse button, navigate to your sample XML file and then select it. You should see that it is displayed in the Schema Viewer pane. Hit the Next button to continue.
This dialog allows you to perform your schema mapping. Two key aspects to this, is to define an Xpath loop expression and the Fields to extract. You can input these values manually, or drag values from the Source Schema pane.
This field allows us to specify an Absolute XPath expression. In our sample XML file, we have a number of ... elements, and these are the elements that we would like to loop through, to produce our raw data.
You can drag the element doc from the Source Schema pane to the Absolute XPath expression.
Fields to extract
We can now specify the fields to extract. As with the Xpath loop expression, we can drag these elements from the Source Schema pane. The elements of interest are title, URL, and abstract. Drag these elements across to Relative or absolute XPath expression fields, in the Fields to extract the grid.
The Fields to extract grid allows you to specify both the Relative or absolute XPath expression and the (output) Column Name. You’ll see from the following screenshot, that the element abstract has been renamed to the abstract text. This is because abstract is a Java reserved word.
Now that you’ve completed the mapping hit the Refresh Preview button that can be found on the Preview pane. The dialog should now look like the following screenshot, including the Preview pane that shows correctly mapped row data. Once the file has been correctly mapped, hit the Next button to proceed.
Related Article: Talend Tutorial |
You will now be presented with the definition of the output Schema. Talend has made it’s best effort at correctly defining this schema, by sampling the available data. The datatypes have been correctly mapped; however, we can now take the opportunity to increase the column lengths, as shown in the next screenshot. When you are happy that you schema is correctly defined, hit the Finish button to complete this operation.
Conclusion
You have now successfully defined an XML input file definition and can use this within your Jobs, to read and process XML data.
Explore TALEND Sample Resumes! Download & Edit, Get Noticed by Top Employers! |
Name | Dates | |
---|---|---|
Talend Training | Oct 15 to Oct 30 | View Details |
Talend Training | Oct 19 to Nov 03 | View Details |
Talend Training | Oct 22 to Nov 06 | View Details |
Talend Training | Oct 26 to Nov 10 | View Details |
I am Ruchitha, working as a content writer for MindMajix technologies. My writings focus on the latest technical software, tutorials, and innovations. I am also into research about AI and Neuromarketing. I am a media post-graduate from BCU – Birmingham, UK. Before, my writings focused on business articles on digital marketing and social media. You can connect with me on LinkedIn.