Kony Fabric console User Guide: Integration > Advanced Configurations > XPath supported operators in Kony Fabric

XPath in Kony Fabric

XPath (XML Path Language) is a query language for selecting nodes from an XML document. Kony Fabric supports XPath expressions to compute/filter (for example, strings, numbers, or Boolean values) a back-end response that is in XML format. Kony supports XPath for XML, SOAP, and JSON integration services.

For more information about XPath, refer https://www.w3schools.com/xml/xml_xpath.asp.

XPath supported operators in Kony Fabric

The following table details the supported operators for XPath expressions in Kony Fabric.

Operators Description
AND Boolean and
OR Boolean or
+ Plus
- Minus
* Multiply
Div Division
Mod Modulus (division remainder)
Sum This converts the value of each node in the node-set to a number and totals the result.
Round This returns the closest integer to the argument. The rounding rules follow Java conventions which are not quite the same as the XSL rules.

 

How to use XPath in Kony Fabric

  1. Create an integration service of an app for XML, SOAP, or JSON.
  2. Create an operation.
  3. Configure the input parameters in the Request Input.

    For example:

  4. Select the environment from the Select an Environment list.
  5. Click Save and Fetch Response to view the results of the operation.

    The back-end response is displayed in the XML format, in the Test Result section.
    In Backend Response window, you can view the raw response as either raw data or in a tree format.

    Clicking on an element in the tree to display the XPath of that tag.

  6. Now apply XPath expressions for extracting the required elements from the back-end response of the service call.

    For example, the following is a sample XPath expressions

    Name/ID XPath Scope Data Type Collection ID Record ID
    articles //channel response Collection    
    articles2 //channel response Record articles  
    title item/title response Sting string   articles2
    url item/media:group/media:content/@url response Sting string   articles2
    • Collection - A group of data, also referred to as data set. A collection contains only records, and a record contains a string, boolean, or number values.
    • Record - A group data elements under the specified parameter. A record can also be part of a collection. Typically, a record provides metadata to a segment.

    Note: For JSON integration service, the back-end response will be in JSON format. JSONPath format should contain $ in the expression.

    For example: $ the root object/element

  7. Click Save and Fetch Response again.

    Now the back-end response is filtered based on the XPath expressions and displays the output in JSON format.

XPath Example Reference

The following example details a sample backend response, and XPath configurations and Output Result based on the XPath configurations

 

Copyright © 2020 Kony, Inc. All rights reserved.