The XML Parser Transformation in Informatica is an Active and Connected transformation. This transformation is useful for extracting XML data from files inside a pipeline.
This article 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 Informatica 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
This article 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 configuring the XML Parser Transformation, 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 must provide the Admin Username and password specified while installing the Server.
Step 1: Source Definition for XML Parser Transformation in Informatica
Once you connect successfully, navigate to Source Analyzer to define your Sources. As we said before, we use the XML file present in the local File System as our source definitions. So, Please navigate to the 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 understand 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 the Delimiter section, please select the delimiter
Here, we can edit the Column Name, Data type, Length or Precision, Scale, and Width. 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 use 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 Informatica XML Parser Transformation Mapping
To create a new mapping, navigate to the 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 the OK button.
TIP: Please refer Mapping article to understand the procedure for creating Mapping.
Drag and drop the XML Customers flat file from the 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 XML Parser Transformation in Informatica
To create Informatica XML Parser Transformation, Please navigate to the Transformation menu in Menu Bar and select the Create.. option.
Once you click the Create.. option, the 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 the Create.. button, a new window called Import XML Definition will be opened, as shown below. Here, you must specify the XSD or XML definition for this XML file.
- Local File: Select this option if the file is a local file system.
- URL: Select the file at a particular URL.
- Non-XML Sources: If the source is a Non-XML file (SQL table) and if it is present in the Source definition.
- Non-XML Targets: If the source is a Non-XML file and is present in the 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, the following window opens. Change XML Views Creation and naming Options 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 XML Parser Transformation in Informatica example, we use the Entity relation XSD. So, we are selecting the first option.
Once you click on the Finish button, XML Parser Transformation in Informatica workspace is added to the mapping designer.
First, 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 must create the workflow. Power Center Workflow manager provides two approaches to creating a workflow.
In this Informatica XML Parser Transformation example, we will create the Workflow manually. To do so, 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 have created the workflow, our next step is to create a session task for our mapping.
Step 4(a): Create Session for Informatica XML Parser Transformation
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 the 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 the Create button, a new Mappings window opens. Here you have to select the mapping you want to associate with this session, i.e., m_XMLParser.
Double click on the Session task will open the Edit Tasks window. We have to configure the Source and Target Connections within the mappings tab. First, let us set the Source connection by clicking on the SQ_XMLCustomers 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 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 the Workflows menu and select the Start Workflow option.
Let’s open the SQL Server Management Studio and write the following SQL Query to check whether we successfully transferred XML data into the table.