XPaths in BizTalk- Message Assignment and Expression Shape

How to set a value using XPath?
xpath(msgGetInputMessage,”/*[local-name()=’procLoadFile’ and namespace-uri()=’http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo’]/*[local-name()=’Data’ and namespace-uri()=’http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo’]”) = varXmlData;
How to get a value using XPath?
varFileName = xpath(msgOutputMessage,”/*[local-name()=’Request’ and namespace-uri()=’http://TestBizBAM3.Request’]/*[local-name()=’Header’ and namespace-uri()=’http://TestBizBAM3.Request’]/*[local-name()=’ReqID’ and namespace-uri()=’http://TestBizBAM3.Request’]”);
Here are some important points to remember regarding XPath:
- It’s not recommended to use XPath for repeating tags, whether they are elements or attributes.
- To obtain the instance XPath query from either an attribute or an element, follow these steps: – Open the schema in Visual Studio and click on the desired element or attribute – Check the property window and copy the complete Instance XPath (as shown in the picture of XPath)
- To avoid any data conversion errors, it is recommended to retrieve values using the appropriate datatype function such as string, number, etc.
varFileName = xpath(msgOutputMessage,”string(xpath query)”);
varFileSize = xpath(msgOutputMessage,”number(xpath query)”);
varRecordsCount = xpath(msgOutputMessage,”count(copy xpath node value from schema)”);
