XML Parser Transformation in Informatica

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 Informatica XML Parser Transformation example, we are going to use the below show XML file

XML Parser Transformation in Informatica 1

XSD that we are going to use is:

XML Parser Transformation in Informatica 2

And the Destination table is Customer Record. As you can see, it is an Empty table

XML Parser Transformation in Informatica 3

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 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 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 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

XML Parser Transformation in Informatica 4

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 in Informatica article to under the following steps.

XML Parser Transformation in Informatica 5

Once you click the Open button, a new pop up window called Flat File Import Wizard will open.

XML Parser Transformation in Informatica 6

Within Step 2: Under Delimiter section, please select the delimiter

XML Parser Transformation in Informatica 7

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.

XML Parser Transformation in Informatica 8

From the below screenshot you can observe that, you can see our newly created Flat File source in Informatica.

XML Parser Transformation in Informatica 9

Step 2: Create Target Definition for XML Parser Transformation in Informatica

Please navigate to Informatica Target Designer to define the Target for XML Parser Transformation. 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

XML Parser Transformation in Informatica 10

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.

XML Parser Transformation in Informatica 11

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 Informatica Mapping article to understand the procedure to create Mapping

XML Parser Transformation in Informatica 12

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.

XML Parser Transformation in Informatica 13

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

XML Parser Transformation in Informatica 14

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.

XML Parser Transformation in Informatica 15

Click Yes or No as per your requirement

XML Parser Transformation in Informatica 16

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.

XML Parser Transformation in Informatica 17

It will open an XML wizard. Click Next button

XML Parser Transformation in Informatica 18

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.

XML Parser Transformation in Informatica 19

Once you click on the Finish button, XML Parser Transformation in Informatica workspace added to the mapping designer.

XML Parser Transformation in Informatica 20

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.

XML Parser Transformation in Informatica 21

Next, connect the XML Parser Transformation fields to the Customer record Target table.

XML Parser Transformation in Informatica 22

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.

XML Parser Transformation in Informatica 23

It will open the Create Workflow window. Please provide the unique name () and leave the default settings.

XML Parser Transformation in Informatica 24

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 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.

XML Parser Transformation in Informatica 25

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.

XML Parser Transformation in Informatica 26

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: 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.
XML Parser Transformation in Informatica 27

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)

XML Parser Transformation in Informatica 28

Change the Target Load type based on your requirement

XML Parser Transformation in Informatica 29

Next, navigate to Workflows Menu and select the Validate option to validate the Workflow.

XML Parser Transformation in Informatica 30

Now, Let me start the Informatica XML Parser Transformation Workflow. To do so, navigate to the Workflows menu and select the Start Workflow option.

XML Parser Transformation in Informatica 31

Let’s open the SQL Server Management Studio and write following SQL Query to check whether we successfully transfered XML data into the table or not.

XML Parser Transformation in Informatica 32