Component family |
XML |
|
Function |
tExtractXMLField reads an input |
|
Purpose |
tExtractXMLField opens an input |
|
Basic settings |
Property type |
Either Built-in or Repository. Click Edit schema to make changes to the schema. If the
|
|
|
Built-in: No property data is |
|
|
Repository: Properties are stored |
|
Schema type and Edit |
A schema is a row description. It defines the number of fields to be processed and passed on |
|
|
Built-In: You create and store the schema locally for this |
|
|
Repository: You have already created the schema and |
|
XML field |
Name of the XML field to be processed. Related topic: see Talend Studio User |
|
Loop XPath query |
Node of the XML tree, which the loop is based on. |
|
Mapping |
Column: reflects the schema as
XPath Query: Enter the fields to be
Get nodes: Select this check box to |
|
Limit |
Maximum number of rows to be processed. If Limit is 0, no rows are Note that this field is not available to the |
|
Die on error |
Select this check box to stop the execution of the Job when an error occurs. Clear the check box to skip any rows on error and complete the process for error-free rows. |
Advanced settings |
Ignore the namespaces |
Select this check box to ignore namespaces when reading and |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a Note that this field is not available to the |
|
Global Variables |
ERROR_MESSAGE: the error message generated by the NB_LINE: the number of rows processed. This is an After A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
Usage |
This component is an intermediate component. It needs an input and |
|
Usage in Map/Reduce Jobs |
If you have subscribed to one of the Talend solutions with Big Data, you can also For further information about a Talend Map/Reduce Job, see the sections Note that in this documentation, unless otherwise explicitly stated, a scenario presents |
|
Log4j |
The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html. |
|
Limitation |
n/a |
This three-component scenario allows to read the XML structure included in the fields
of a database table and then extracts the data.
-
Drop the following components from the Palette onto the design workspace: tMysqlInput, tExtractXMLField,
and tFileOutputDelimited.Connect the three components using Main
links. -
Double-click tMysqlInput to display its
Basic settings view and define its
properties. -
If you have already stored the input schema in the Repository tree view, select Repository first from the Property
Type list and then from the Schema list to display the [Repository
Content] dialog box where you can select the relevant metadata.For more information about storing schema metadata in the Repository tree view, see Talend Studio User
Guide.If you have not stored the input schema locally, select Built-in in the Property Type
and Schema fields and enter the database
connection and the data structure information manually. For more information
about tMysqlInput properties, see tMysqlInput. -
In the Table Name field, enter the name of
the table holding the XML data, customerdetails in this
example.Click Guess Query to display the query
corresponding to your schema. -
Double-click tExtractXMLField to display its
Basic settings view and define its
properties. -
Click Sync columns to retrieve the schema
from the preceding component. You can click the three-dot button next to
Edit schema to view/modify the
schema.The Column field in the Mapping table will be automatically populated with the defined
schema. -
In the Xml field list, select the column from
which you want to extract the XML data. In this example, the filed holding the
XML data is called CustomerDetails.In the Loop XPath query field, enter the node
of the XML tree on which to loop to retrieve data.In the Xpath query column, enter between
inverted commas the node of the XML field holding the data you want to extract,
CustomerName in this example. -
Double-click tFileOutputDelimited to display
its Basic settings view and define its
properties. -
In the File Name field, define or browse to
the path of the output file you want to write the extracted data in.Click Sync columns to retrieve the schema
from the preceding component. If needed, click the three-dot button next to
Edit schema to view the schema. -
Save your Job and click F6 to execute
it.
tExtractXMLField read and extracted the clients names
under the node CustomerName
of the CustomerDetails
field of the defined database table.
This scenario describes a four-component Job that reads an XML structure from a
delimited file, outputs the main data and rejects the erroneous data.
-
Drop the following components from the Palette to the design workspace: tFileInputDelimited, tExtractXMLField, tFileOutputDelimited and tLogRow.
Connect the first three components using Row
Main links.Connect tExtractXMLField to tLogRow using a Row
Reject link. -
Double-click tFileInputDelimited to open its
Basic settings view and define the
component properties. -
Select Built-in in the Schema list and fill in the file metadata manually in the
corresponding fields.Click the three-dot button next to Edit
schema to display a dialog box where you can define the structure
of your data.Click the plus button to add as many columns as needed to your data structure.
In this example, we have one column in the schema:
xmlStr.Click OK to validate your changes and close
the dialog box.Note
If you have already stored the schema in the Metadata folder under File
delimited, select Repository
from the Schema list and click the
three-dot button next to the field to display the [Repository Content] dialog box where you can select the
relevant schema from the list. Click Ok to
close the dialog box and have the fields automatically filled in with the
schema metadata.For more information about storing schema metadata in the Repository tree
view, see Talend Studio User Guide. -
In the File Name field, click the three-dot
button and browse to the input delimited file you want to process,
CustomerDetails_Error in this example.This delimited file holds a number of simple XML lines separated by double
carriage return.Set the row and field separators used in the input file in the corresponding
fields, double carriage return for the first and nothing for the second in this
example.If needed, set Header, Footer and Limit. None is used
in this example. -
In the design workspace, double-click tExtractXMLField to display its Basic
settings view and define the component properties. -
Click Sync columns to retrieve the schema
from the preceding component. You can click the three-dot button next to
Edit schema to view/modify the
schema.The Column field in the Mapping table will be automatically populated with the defined
schema. -
In the Xml field list, select the column from
which you want to extract the XML data. In this example, the filed holding the
XML data is called xmlStr.In the Loop XPath query field, enter the node
of the XML tree on which to loop to retrieve data. -
In the design workspace, double-click tFileOutputDelimited to open its Basic
settings view and display the component properties. -
In the File Name field, define or browse to
the output file you want to write the correct data in,
CustomerNames_right.csv in this example.Click Sync columns to retrieve the schema of
the preceding component. You can click the three-dot button next to Edit schema to view/modify the schema. -
In the design workspace, double-click tLogRow
to display its Basic settings view and define
the component properties.Click Sync Columns to retrieve the schema of
the preceding component. For more information on this component, see tLogRow. -
Save your Job and press F6 to execute it.
tExtractXMLField reads and extracts in the output
delimited file, CustomerNames_right, the client information for
which the XML structure is correct, and displays as well erroneous data on the console
of the Run view.