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.
| Operator | Description | Example |
| and | Logical-and | price>9.00 and price<9.90 author[degree and award] //Item[Price > 100 and @Type=’Bulk’] |
| or | Logical-or | price=9.80 or price=9.70 |
| not() | Negation | |
| = | Equality | price=9.80 author[last-name = "Bob"] //Item[Status=’Active’] |
| != | Not equal | price!=9.80 degree[@from != "Harvard"] //Item[Status!=’Cancelled’] |
| < * | Less than | price < 9.80 |
| <= * | Less than or equal | price <= 9.80 book[position() <= 3] |
| > * | Greater than | price > 9.80 |
| >= * | Greater than or equal | price >= 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.
| Operator | Description | Example |
| / | 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 > 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 |
| div | Performs floating-point division according to IEEE 754. | 8 div 4 results in 2 |
| * | Performs multiplication. | 6 * 4 results in 24 |
| mod | Returns 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.