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

  • Sandro Pereira
  • Aug 29, 2009
  • 4 min read

In BizTalk Server, XPath is the “scalpel” you use to perform surgery on XML messages. While the Mapper handles basic tasks, Orchestration expressions and advanced XSLT require you to know the exact syntax for operators and special characters.

📝 One-Minute Brief

Navigating XML messages in BizTalk requires a solid grasp of XPath syntax. This quick reference guide covers essential XPath 1.0 operators—including mathematical, comparison, and boolean logic—as well as special characters like wildcards and axes. Whether you are using the xpath() function in an Orchestration or writing custom XSLT in a map, this cheat sheet helps you build precise queries to filter and manipulate your data effectively.

Here is a quick-reference guide to the XPath 1.0 syntax supported by BizTalk.

Operators

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.

OperatorDescriptionExample
andLogical-andprice>9.00 and price<9.90
author[degree and award]
//Item[Price > 100 and @Type=’Bulk’]
orLogical-orprice=9.80 or price=9.70
not()Negation 
=Equalityprice=9.80
author[last-name = "Bob"]
//Item[Status=’Active’]
!= Not equalprice!=9.80
degree[@from != "Harvard"]
//Item[Status!=’Cancelled’]
&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.

OperatorDescriptionExample
/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.

/Order/Header
//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.

//Price
.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.

./@ID
..The parent of the current context node.author[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.

../LineItem
*Wildcard; selects all elements regardless of the element name.author/*
All element children of <author> elements

/Order/*
@Attribute; prefix for an attribute name.price/@exchange
The exchange attribute of <price> elements within the current context.

//@Currency
@*Attribute wildcard; selects all attributes regardless of name. 
:Namespace separator; separates the namespace prefix from the element or attribute name.my:book
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

Common BizTalk Pitfall: The Local-Name Trick

Because BizTalk messages heavily use namespaces, many developers prefer using this syntax to avoid namespace prefix issues: /*[local-name()='Order']/*[local-name()='Total']

XPath 1.0 may be a simple language, but its operators allow for incredibly complex logic within your BizTalk solutions. Bookmark this page for the next time you’re stuck in an Expression Shape!

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
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 *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top