BizTalk Mapping Tips 01: Using XPath Expressions

Every time I have ever tried using an XPath expression inside an
orchestration, I only managed to generate XLANG errors in the event log.
Well, today I found this blog post that clued me in to the magic
that makes XPath work in BizTalk. When using the xpath() function within
an orchestration, make sure you wrap the XPath expression itself within
a string() function call. A properly formatted XPath expression would
look like this:

myVar = xpath(myMessage, "string(/*[local-name()='MyRootNode'])");

This works beautifully in BizTalk 2006 R2.