Datapolis Process System

Search:

Contents
:
IndexBookmarkPrint
Home > Tutorials > Parse Document Library XML File

Parse Document Library XML File

 

This tutorial will show you how to get specific node value from file in Document Library.

In this tutorial it is assumed that reader knows how to create workflows and use activities and functions.

 

Please read Calling REST Services tutorial before this one.

 

Introduction


For get xml node value of file that was uploaded to Document Library you need to use two functions:

  • Get node or attribute from XML category
  • Call REST Service from Data Sources category

 

You need to use second function as a parameter value for first one. 

Parsing XML File


Lets image you have XML File in document library that contains below XML:

 

<SomeRootNode><SomeOtherNode>SomeValue</SomeOtherNode></SomeRootNode>

 

and you would like to get SomeValue text. For achieving this you need to configure your  Get node or attribute function as below:

 

  • XML: Put here lookup to Call REST Service function which will download your file.
  • XPath: Provide here XPath query that will get interesting node: /SomeRootNode/SomeOtherNode
  • Separator: Not needed in this example
  • Namespace: Also not needed to provide value in this example

 

Getting XML File Content


To get XML File content you need to use Call REST Service function as a parameter of Get node or attribute function. This function should connect to SharePoint REST Service and download file. It should be configured as below:

 

  • Request URI: http://sp/web/_api/web/lists/getbytitle('DocumentLibrary')/items(ItemId)/File/$value?binaryStringResponseBody=true

Where http://sp/web is address of web site where Document Library is located, DocumentLibrary is a name of Document Library and ItemId is ID of an item on this Document Library. E.g. http://sp/myweb/_api/web/lists/getbytitle('Documents')/items(2)/File/$value?binaryStringResponseBody=true

  • Login: Username of user who will connect (you may specify some special service account)
  • Password: Password of above account
  • Authentication Type: Usually NTML or Kerberos - depending on you environment.
  • Content Type: Leave empty in this example
  • Headers: Leave empty in this example
  • Method: Provide GET as method name.
  • Post data: Also leave empty, becouse of using GET method.

 

Result


As a result of using above functions you should get SomeValue text got from example xml. Of course you may use any other XML file and XPath query to get real data you need.