The XML Parser Transformation in Informatica is an Active and Connected transformation. This transformation is useful to extract XML data from files inside a pipeline.
In this article, we will show you how to use XML Parser Transformation in Informatica to extract data from an XML file and load it into the Database table with an example.
For this XML Parser Transformation example, we are going to use the below show XML file
XSD that we are going to use is:
And the Destination table is Customer Record. As you can see, it is an Empty table
XML Parser Transformation in Informatica Example
In this article, we will show you how to use this Parser Transformation in Informatica to read XML data from the CSV file to the SQL Database table.
Before we start configuring, First, let me connect with the Informatica repository service. To do so, we have to provide the Admin Console credentials. So, Please provide the appropriate Username and Password, and click the Connect button.
TIP: Here you have to provide the Admin Username and password that you specified while installing the Server.
Step 1: Source Definition for XML Parser Transformation in Informatica
Once you connected successfully, Please navigate to Source Analyzer to define your Sources. As we said before, we are using the XML file present in the local File System as our source definitions. So, Please navigate to Source menu, and select the Import from File.. option
Once you choose the Import from File.. option, a new window called Open Flat File will open. Please select the XMLCustomers.csv file from your local file system and click the Open button. I suggest you refer Flat File Source article to under the following steps.
Once you click the Open button, a new pop up window called Flat File Import Wizard will open.
Within Step 2: Under Delimiter section, please select the delimiter
Here, we can edit the Column Name, Data type, Length or Precision, Scale, and Width. In general, we don’t do that, but if you want, you can do it.
From the below screenshot you can observe that we can see our newly created Flat File source.
Step 2: Create Target Definition for XML Parser Transformation in Informatica
Please navigate to Target Designer to define the Target for Informatica XML Parser Transformation. In this example, we are using the existing SQL table (Customer Record) as our target definition. You can refer to Create Target table using Source Definition to understand the process of creating a target definition
Step 3: Create a Mapping
To create a new mapping, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.
It will open the Mapping Name window to write a unique name for this Mapping. Let me write m_XMLParser and click OK button.
TIP: Please refer Mapping article to understand the procedure to create Mapping
Drag and drop the XML Customers flat file from Sources folder to the mapping designer. Once you drag the source, the Power Center designer will automatically create the source qualifier for you. I suggest you refer to the Source Qualifier Transformation article.
Step 3(a): Create a XML Parser Transformation in Informatica
To create XML Parser Transformation, Please navigate to the Transformation menu in Menu Bar and select the Create.. option.
Once you click on the Create.. option, Create Transformation window will open. Please select the XML Parser Transformation from the drop-down list and specify the unique name (XML_ParseCustomer) and click on Create button
Once you click on the Create.. button, a new window called Import XML Definition will be opened as shown below. Here, you have to specify the XSD or XML definition for this XML file.
- Local File: If the file is a local file system, then select this option.
- URL: Select the file at particular URL
- Non-XML Sources: If the source is a Non-XML file (SQL table) and if it is present in the Informatica Source definition.
- Non-XML Targets: If the source is a Non-XML file, and if it is present in the Informatica Target definition
Please select the CustomerXSD.xml file from your local file system and click the Open button.
Click Yes or No as per your requirement
If you select Yes from the above screenshot then the following window opens. Change XML Views Creation and naming Option will be displayed. Please change the options as per your requirements.
It will open an XML wizard. Click Next button
Every XML file has to be processed using a Valid XML Definition (or XSD). Please define the XML definition in the second page.
In this example, we are using the Entity relation XSD. So, we are selecting the first option.
Once you click on the Finish button, XML Parser Transformation in Informatica workspace added to the mapping designer.
First, let me add the XML field from Source Qualifier to XML Parser Transformation. Next, Drag and drop the target definition from the Targets folder to the mapping designer.
Next, connect the XML Parser Transformation fields to the Customer record Target table.
Step 4: Create a Workflow for XML Parser Transformation in Informatica
After we finish creating the Mapping, we have to create the workflow for it. Power Center Workflow manager provides two approaches to create a workflow.
In this Informatica XML Parser Transformation example, we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.
It will open the Create Workflow window. Please provide the unique name () and leave the default settings.
Once we created the workflow, our next step is to create a session task for our mapping.
Step 4(a): Create Session
There are two types of sessions:
For this Informatica XML Parser Transformation example, we created a Non-reusable Session. To create Non-reusable Session, Please navigate to Tasks Menu and select the Create option.
Please provide a unique name for this session. Here, we are naming it as s_XMLParseCustomer. Once you click on the Create button, a new window called Mappings opened. Here you have to select the Mapping that you want to associate with this session, i.e., m_XMLParser.
Double click on the Session task will open the Edit Tasks window. Within the mappings tab, we have to configure the Source and Target Connections. First, let us set the Source connection by clicking on the SQ_XMLCustomers present in the Sources folder.
- Source File directory: It will use the default directory, but you can change the directory by giving the full path. For example, D:\File Examples\
- Source filename: It will automatically detect. If not, please specify the file name along with the extension.
Next, we have to configure the target connection. So, select the CustomerRecord under the targets folder.
Within the Connections, click on the Arrow button beside the Relational type, and select the target table database (Target)
Change the Target Load type based on your requirement
Next, navigate to Workflows Menu and select the Validate option to validate the Workflow.
Now, Let me start the Informatica XML Parser Transformation Workflow. To do so, navigate to the Workflows menu and select the Start Workflow option.