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 XML file and load it into the Database table with an example.
For this 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 XML Parser Transformation in Informatica to read XML data from CSV file to SQL Database table.
Before we start configuring, First let me connect with the Informatica repository service. In order to do so, we have to provide the Informatica 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 Informatica 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 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 as shown below
Once you select the Import from File.. option, a new window called Open Flat File will be opened as shown below. Please select the XMLCustomers.csv file from your local file system and click the Open button. I suggest you refer Flat File Source in Informatica article to under the following steps.
Once you click the Open button, a new pop up window called Flat File Import Wizard will be opened as shown below.
Within the 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, you can see our newly created Flat File source in Informatica
Step 2: Create Target Definition for XML Parser Transformation in Informatica
Please navigate to Target Designer to define the Target. In this example, we are using the existing SQL table (Customer Record) as our target definition. You can refer to Create Informatica Target table using Source Definition to understand the process of creating a target definition
Step 3: Create a Mapping for XML Parser Transformation in Informatica
To create a new mapping, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.
This 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 Informatica 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, Power Center designer will automatically create the source qualifier for you. I suggest you refer the Source Qualifier Transformation article.
Step 3(a): Create a XML Parser Transformation in Informatica
In order to create XML Parser Transformation, Please navigate to Transformation menu in Menu Bar and select the Create.. option as we shown below.
Once you click on the Create.. option, Create Transformation window will be opened as we shown below. 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 following window. Change XML Views Creation and naming Option will be displayed. Please change the options as per your requirements.
This 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 will be 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 Targets folder to the mapping designer.
Next, connect the XML Parser Transformation fields to 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 example, we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.
This will open Create Workflow window as shown below. 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 for XML Parser Transformation in Informatica
There are two types of sessions in Informatica:
For this example, we created a Non-reusable Session. In order to create Non-reusable Session, Please navigate to Tasks Menu and select the Create option as shown below.
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 will be 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 configure the Source connection by clicking on the SQ_XMLCustomers present in the Sources folder.
- Source File directory: Informatica 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 (Informatica 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 Workflow. To do so, navigate to the Workflows menu, and select the Start Workflow option.
Thank You for Visiting Our Blog