Xpath is a function that can be used in any orchestration to set and retrieve data from/to messages.

The syntax is very simple:

  1. Set a value in message
    xpath(message, "xpathQuery") = value;
  2. Get a value from message
    variable = xpath(message, "xpathQuery");

The first problem that all users complains it's how to get the xpath of a specific message element. This can be achieved by going to the properties of the chosen element and copy the "Instance XPath" property value.

 

Another problem is using Xpath function to get message elements data. When you want to get a string value to a string variable, for example, you must use the xpath string function.

stringVariable = xpath(message, "string(xpathQuery)");

For a number value

intVariable = xpath(message, "number(xpathQuery)");

If you want to use the Xpath function to get xml data to a XmlDocument variable you must not use any xpath function.

xmlDocumentVariable = xpath(message, "xpathQuery");

Some examples:

booleanVar = xpath(message, "boolean(/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='IntField' and namespace-uri()=''])");

xmlVariable = xpath(message, "/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='anyField' and namespace-uri()='']");

xpath(message, "/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='anyField' and namespace-uri()='']") = xmlVariable.InnerXml;

xpath(message, "/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='BooleanField' and namespace-uri()='']") = booleanVar;

xpath(message, "/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='IntField' and namespace-uri()='']") = 3;

LEAVE A REPLY

Please enter your comment!
Please enter your name here