136 Citrix NetScaler Policy Configuration and Reference Guide

XPath and JSON Expressions

The advanced expression engine supports expressions for evaluating and retrieving data from XML and JavaScript Object Notation (JSON) files. This enables you to find specific nodes in an XML or JSON document, determine if a node exists in the file, locate nodes in XML contexts (for example, nodes that have specific parents or a specific attribute with a given value), and return the contents of such nodes. Additionally, you can use XPath expressions in rewrite expressions.

The advanced expression implementation for XPath comprises an advanced expression prefix (such as “HTTP.REQ.BODY”) that designates XML text and the XPATH operator that takes the XPath expression as its argument.

JSON files are either a collection of name/value pairs or an ordered list of values. You can use the XPATH_JSON operator, which takes an XPath expression as its argument, to process JSON files.

XPath and JSON Expression Prefixes that Return Text

XPath Prefix

Description

 

 

text.XPATH(xpathex)

Operate on an XML file and return a Boolean

 

value.

 

For example, the following expression returns

 

a Boolean TRUE if a node called “creator”

 

exists under the node “Book” within the first

 

1000 bytes of the XML file.

 

HTTP.REQ.BODY(1000).

 

XPATH(xp%boolean(//Book/creator)%)

 

Parameters:

 

xpathex - XPath Boolean expression

 

 

text.XPATH(xpathex)

Operate on an XML file and return a value of

 

data type “double.”

 

For example, the following expression

 

converts the string “36” (a price value) to a

 

value of data type “double” if the string is in

 

the first 1000 bytes of the XML file:

 

HTTP.REQ.BODY(1000).

 

XPATH(xp%number(/Book/price)%)

 

Parameters:

 

xpathex - XPath numeric expression

 

 

Page 150
Image 150
Citrix Systems 9.2 manual XPath and Json Expressions, XPath and Json Expression Prefixes that Return Text