BizTalk Working With XPath – XPath 1.0 Operators and Special Characters Quick Reference

Posted: August 29, 2009  |  Categories: BizTalk


Boolean, Comparison, and Set Expressions

Filter patterns can contain Boolean expressions, comparison expressions, and set expressions. Shortcuts listed in the following table represent alternative symbols that are provided in this XSL Transformations (XSLT) implementation. This article discusses these expression operators.

andLogical-andprice>9.00 and price<9.90
author[degree and award]
orLogical-orprice=9.80 or price=9.70
author[last-name = "Bob"]
!= Not equalprice!=9.80
degree[@from != "Harvard"]
&lt; *Less thanprice &lt; 9.80
&lt;= *Less than or equalprice &lt;= 9.80
book[position() &lt;= 3]
&gt; *Greater thanprice &gt; 9.80
&gt;= *Greater than or equalprice &gt;= 9.80
|Set operation; returns the union of two sets of nodes//book | //cd
Returns a node-set with all book and cd elements

Operators and Special Characters

XPath expressions are constructed using the operators and special characters shown in the following table.

/Child operator; selects immediate children of the left-side collection. When this path operator appears at the start of the pattern, it indicates that children should be selected from the root node./bookstore
The document element (<bookstore>) of this document.
//Recursive descent; searches for the specified element at any depth. When this path operator appears at the start of the pattern, it indicates recursive descent from the root node.//author
All <author> elements in the document.
.Indicates the current context../first-name
All <first-name> elements in the current context node. Note that this is equivalent to the expression in the next row.
..The parent of the current context[last-name = “Bob” and ../price &gt; 50]
All <author> elements that contain a <last-name> child element whose value is Bob, and a <price> sibling element whose value is greater than 50.
*Wildcard; selects all elements regardless of the element*
All element children of <author> elements
@Attribute; prefix for an attribute name.price/@exchange
The exchange attribute of <price> elements within the current context.
@*Attribute wildcard; selects all attributes regardless of name. 
:Namespace separator; separates the namespace prefix from the element or attribute
The <book> element from my namespace.
( )Groups operations to explicitly establish precedence. 
[ ]Applies a filter pattern. 
+Performs addition.6 + 4 results in 10
Performs subtraction.6 – 4 results in 2
divPerforms floating-point division according to IEEE 754.8 div 4 results in 2
*Performs multiplication.6 * 4 results in 24
modReturns the remainder from a truncating division.5 mod 2  results in 1
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More

Manage and monitor serverless
components effortlessly

Learn More
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top