Xpath Cheat Sheet

It seems as though every orchestration I'm trying to xpath something either into or out of a message in BizTalk.  So I'm creating a simple cheat sheet that I can refer to.

To set a single value inside a message:

xpath(msg_YourMessage, "Node Instance XPath") = str_YourValue;

To extract a single value from a Message:

str_YourValue = (System.String)xpath(msg_YourMessage,"string(Node Instance XPath)");

Note: I like casting the xpath result to a System.String so I can have complete access to all the System.String methods/properties inside of the Expression Shape

Extract a single value from a looping segment by index:

str_Xpath= System.String.Format("Node Instance XPath[{0}]",int_Index);

xDoc = xpath(msg_YourMessage, str_Xpath);

Count the number of nodes inside the message:

int_NumberofNodes = System.Convert.ToInt32(xpath(msg_YourMessage, "count(Node Instance Xpath)"));

posted @ Thursday, August 07, 2008 4:08 PM

Print

Comments on this entry:

 re: Xpath Cheat Sheet

Left by sandhya at 3/31/2010 11:55 PM

thanks. this is reallyhelpfull

Your comment:



 (will not be displayed)


 
 
 
Please add 2 and 3 and type the answer here:
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789