-
AppExpert Applications and Templates
-
Configure application authentication, authorization, and auditing
-
-
Advanced Policy Expressions: Working with Dates, Times, and Numbers
-
Advanced Policy Expressions: Parsing HTTP, TCP, and UDP Data
-
Expressions for Identifying the Protocol in an Incoming IP Packet
-
Expressions for HTTP Status Codes and Numeric HTTP Payload Data Other Than Dates
-
Operations for HTTP, HTML, and XML Encoding and “Safe” Characters
-
Expressions for Evaluating a DNS Message and Identifying Its Carrier Protocol
-
XPath and HTML, XML, or JSON Expressions
-
Advanced Policy Expressions: IP and MAC Addresses, Throughput, VLAN IDs
-
-
This content has been machine translated dynamically.
Dieser Inhalt ist eine maschinelle Übersetzung, die dynamisch erstellt wurde. (Haftungsausschluss)
Cet article a été traduit automatiquement de manière dynamique. (Clause de non responsabilité)
Este artículo lo ha traducido una máquina de forma dinámica. (Aviso legal)
此内容已经过机器动态翻译。 放弃
このコンテンツは動的に機械翻訳されています。免責事項
이 콘텐츠는 동적으로 기계 번역되었습니다. 책임 부인
Este texto foi traduzido automaticamente. (Aviso legal)
Questo contenuto è stato tradotto dinamicamente con traduzione automatica.(Esclusione di responsabilità))
This article has been machine translated.
Dieser Artikel wurde maschinell übersetzt. (Haftungsausschluss)
Ce article a été traduit automatiquement. (Clause de non responsabilité)
Este artículo ha sido traducido automáticamente. (Aviso legal)
この記事は機械翻訳されています.免責事項
이 기사는 기계 번역되었습니다.책임 부인
Este artigo foi traduzido automaticamente.(Aviso legal)
这篇文章已经过机器翻译.放弃
Questo articolo è stato tradotto automaticamente.(Esclusione di responsabilità))
Translation failed!
XPath and HTML, XML, or JSON expressions
The Advanced policy infrastructure supports expressions for evaluating and retrieving data from HTML, XML, and JavaScript Object Notation (JSON) files. This enables you to find specific nodes in an HTML, 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 policy expression implementation for XPath comprises an Advanced policy expression prefix (such as “HTTP.REQ.BODY”) that designates HTML or XML text, and the XPATH operator that takes the XPath expression as its argument.
HTML files are a largely free-form collection of tags and text elements. You can use the XPATH_HTML operator, which takes an XPath expression as its argument, to process HTML files. 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.
-
<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
Example:
<Book>
<creator>
<Person>
<name>Milton</name>
</Person>
</creator>
<title>Paradise Lost</title>
</Book>
<!--NeedCopy-->
-
<text>.XPATH(xpathex):
Operate on an XML file and return a node-set or a string. Node-sets are converted to corresponding strings by using the standard XPath string conversion routine.
For example, the following expression selects all the nodes that are enclosed by “/Book/creator” (a node-set) in the first 1000 bytes of the body:
HTTP.REQ.BODY(1000).XPATH(xp%/Book/creator%)
Parameters:
xpathex - XPath expression
-
<text>.XPATH_HTML(xpathex)
Operate on an HTML file and return a text value.
For example, the following expression operates on an HTML file and returns the text enclosed in
<title\></title\>
tags if the title HTML element is found in the first 1000 bytes:HTTP.REQ.BODY(1000).XPATH_HTML(xp%/html/head/title%)
Parameters:
xpathex - XPath text expression
-
<text>.XPATH_HTML_WITH_MARKUP(xpathex)
Operate on an HTML file and return a string that contains the entire selected portion of the document, including markup such as including the enclosing element tags.
The following expression operates on the HTML file and selects all content within the <\title> tag, including markup.
HTTP.REQ.BODY(1000).XPATH_HTML_WITH_MARKUP( xp%/html/head/title%)
The portion of the HTML body that is selected by the expression is marked for further processing.
Parameters:
xpathex - XPath expression
-
<text>.XPATH_JSON(xpathex)
Operate on a JSON file and return a Boolean value.
For example, consider the following JSON file:
{ “Book”:{ “creator”:{ “person”:{ “name”:’<name>’ } }, “title”:’<title>’ } }
The following expression operates on the JSON file and returns a Boolean TRUE if the JSON file contains a node named “creator,” whose parent node is “Book,” in the first 1000 bytes:
HTTP.REQ.BODY(1000).XPATH_JSON(xp%boolean(/Book/creator)%)
Parameters:
xpathex - XPath Boolean expression
-
<text>.XPATH_JSON(xpathex)
Operate on a JSON file and return a value of data type “double.”
For example, consider the following JSON file:
{ “Book”:{ “creator”:{ “person”:{ “name”:’<name>’ } }, “title”:’<title>’, “price”:”36” } }
The following expression operates on the JSON file and converts the string “36” to a value of data type “double” if the string is present in the first 1000 bytes of the JSON file.
HTTP.REQ.BODY(1000).XPATH_JSON(xp%number(/Book/price)%)
Parameters:
xpathex - XPath numeric expression
-
<text>.XPATH_JSON(xpathex)
Operate on a JSON file and return a node-set or a string. Node-sets are converted to corresponding strings by using the standard XPath string conversion routine.
For example, consider the following JSON file:
{ “Book”:{ “creator”:{ “person”:{ “name”:’<name>’ } }, “title”:’<title>’ } }
The following expression selects all the nodes that are enclosed by “/Book” (a node-set) in the first 1000 bytes of the body of the JSON file and returns the corresponding string value, which is “<name><title>”:
HTTP.REQ.BODY(1000).XPATH_JSON(xp%/Book%)
Parameters:
xpathex - XPath expression
-
<text>.XPATH_JSON_WITH_MARKUP(xpathex)
Operate on an XML file and return a string that contains the entire portion of the document for the result node, including markup such as including the enclosing element tags.
For example, consider the following JSON file:
{“Book”:{ “creator”:{ “person”:{ “name”:’<name>’ } }, “title”:’<title>’ } }
The following expression operates on the JSON file and selects all the nodes that are enclosed by “/Book/creator” in the first 1000 bytes of the body, which is “creator:{ person:{ name:’<name>’ } }.”
HTTP.REQ.BODY(1000).XPATH_JSON_WITH_MARKUP(xp%/Book/creator%)
The portion of the JSON body that is selected by the expression is marked for further processing.
Parameters:
xpathex - XPath expression
-
<text>.XPATH_WITH_MARKUP(xpathex):
Operate on an XML file and return a string that contains the entire portion of the document for the result node, including markup such as including the enclosing element tags.
For example, the following expression operates on an XML file and selects all the nodes enclosed by “/Book/creator” in the first 1000 bytes of the body.
HTTP.REQ.BODY(1000).XPATH_WITH_MARKUP(xp%/Book/creator%)
The portion of the JSON body that is selected by the expression is marked for further processing.
Parameters:
xpathex - XPath expression
Share
Share
In this article
This Preview product documentation is Cloud Software Group Confidential.
You agree to hold this documentation confidential pursuant to the terms of your Cloud Software Group Beta/Tech Preview Agreement.
The development, release and timing of any features or functionality described in the Preview documentation remains at our sole discretion and are subject to change without notice or consultation.
The documentation is for informational purposes only and is not a commitment, promise or legal obligation to deliver any material, code or functionality and should not be relied upon in making Cloud Software Group product purchase decisions.
If you do not agree, select I DO NOT AGREE to exit.