Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Read Attribute values using XPath or Other alternative
- This topic has 1 reply, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
June 28, 2009 at 12:49 AM #22727
Hi,
I need to read from xml during transformation . based on some parameter i need to identify sending location. Following is my xml and XML is generatin from database (SQL Server 2005)
– <ns0:BOAArlineItem xmlns:ns0=”http://BOAArlineItem“>
<ns0:dbo.BELB_History recordbatchnumber=”recordbatchnumber_0″ RecordLockboxnumber=”RecordLockboxnumber_1″ contechdepositdate=”contechdepositdate_2″ EXPORTRECORDLINE=”EXPORTRECORDLINE_3″ />
<ns0:dbo.BELB_History recordbatchnumber=”recordbatchnumber_0″ RecordLockboxnumber=”RecordLockboxnumber_1″ contechdepositdate=”contechdepositdate_2″ EXPORTRECORDLINE=”EXPORTRECORDLINE_3″ />
<ns0:dbo.BELB_History recordbatchnumber=”recordbatchnumber_0″ RecordLockboxnumber=”RecordLockboxnumber_1″ contechdepositdate=”contechdepositdate_2″ EXPORTRECORDLINE=”EXPORTRECORDLINE_3″ />
</ns0:BOAArlineItem>Attributes recordbatchnumber, RecordLockboxnumber and contechdepositdate value would be same in all the record in file
Now I need to read those attribute value and generate sending file name.
I have used xPath to read attribute values from xml. following is the code for reading attribute using xpath
//Get the path of the the first HeaderInfo Element
HeaderInfoPath = System.String.Format(“//dbo.BankExternalLockBox_History[{0}]”,1);
XmlDoc = xpath(BOAArlineItemMSG,HeaderInfoPath);//Construct Message
XmlDocMSG = XmlDoc;LockBoxNo = xpath(XmlDocMSG,”string(/dbo.BankExternalLockBox_History/RecordLockboxnumber)”);
BatchNo = xpath(XmlDocMSG,”string(/dbo.BankExternalLockBox_History/recordbatchnumber)”);SendFileName = LockBoxNo + BatchNo + System.DateTime.Now.Date.ToString() + “.txt”;
OUTBOAArlineMSG(FILE.ReceivedFileName) = SendFileName;
Can anyone suggest how to use xPath within orchestration or suggest other alternative?
Thanks for early response.
Regards,
– Dhaval M.
-
June 29, 2009 at 5:00 AM #22733
I would tend to extract the LockBoxNo and BatchNo from the original message without constructing the XmlDocMSG.
StringXpathBase = “string(/*[local-name()=’BOAArlineItem ‘]/*[local-name()=’dbo.BankExternalLockBox_History’][{0}]/*[local-name()='{1}’])”;
LockBoxNo = xpath(BOAArlineItemMSG, System.String.Format(StringXpathBase,”1″, “RecordLockboxnumber”));
BatchNo = xpath(BOAArlineItemMSGSystem.String.Format(StringXpathBase,”1″, “recordbatchnumber”));Your original xpath statements will not resolve because the message has a namespace. You need to use a predicate i.e.
*[local-name()=‘nodename’]
or
*[local-name()=‘nodename’ and namespace-uri=‘message–namespace’]
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.