Monday, January 4, 2016

How to use XPath in XML Task in SSIS 2014

The XML Task is used when you need to validate, modify, extract, or even create files in an XML format.
In SSIS 2014, there are six operation types are available.


XPath: This option uses the XML Path Language and allows the extraction of sections or specific nodes from the structure of the XML document. You might use this option to extract data from the XML document prior to using the content. For example, you might want to pull out only the orders for a specific customer from an XML file.
In XPath, you can choose one of the operation in the below list box. Node list will retrieve all the nodes based on the XPath and Values will retrieve only values based on the XPath.
In this following example shows how to retire the nodes
The source file contains 3 nodes for book
Configure the XPath as //book and other file path variables and run. To learn about XPath, please follow this link

In the output you can notice that only book elements are retrieved.
Now let see the Value retrieve
If you need to retrieve all the authors first name
If you need to retrieve attribute you need to use @ symbol before the attribute, for example if you need to take all the style of the book
Output:
If you need to take last node:


Cheers!
Uma

2 comments:

  1. I cant figure out how I can add tag on the top and bottom of Xml files. There are multiple files. Will you give me some advise? Thank you.

    ReplyDelete