O'Reilly logo

Professional BizTalk® Server 2006 by Ewan Fairweather, Kevin B. Smith, Darren Jefford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.3. XPath

XPath is a navigation language for finding information held in an XML document. Navigation is described using "expressions," which in their basic form are analogous to the paths you use to navigate the filesystem on Windows.

XPath is used by BizTalk messaging and orchestrations to retrieve interesting pieces of data from a message, which can then be used to route the message or perform a conditional business process. As with namespaces, a little understanding of XPath can go a long way toward helping you diagnose problems during development.

An XPath expression returns a node or collection of nodes called a node set and in some cases the result of a function — a integer representing a count for example. The XPath expression /ps:Person/ps:Name will return the Name node of the following XML document.

<ps:Person  xmlns:ps="http://www.wiley.com/person"
xmlns:ad:="http://www.wiley.com/address">
  <ps:Name>Toby</ps:Name>
  <ps:Age>3</ps:Age>
  <ad:Address>
  <ad:Town>Chippenham</ad:Town>
  </ad:Address>
</ps:Person>

As you may have noticed, the namespace prefixes have been used in the XPath expression. Because XPath is "namespace aware," if namespaces are omitted, it will be unable to find the node. Omitting the namespaces in this way will cause XPath to use only the default namespace. So if /Person/Name were to be used, it would not exist outside of the correct namespace.

The .NET code to retrieve the Name element from the preceding document is shown below. Note that the namespace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required