Question

I am trying to find the IMD in the last Line element in my edifact file, using xpath in biztalk - orchestration. This is my xpath:

LastLineName = xpath(Message_2,"/*[local-name()='EFACT_D96A_INVOIC' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='LINLoop1' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='IMD_2' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='C273_2' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='C27304' and namespace-uri()='']last()");

And this is my edifat-file:

UNB+UNOB:1+BTS-SENDER:ZZZ+RECEIVE-PARTNER:ZZZ+130418:1513+19++++0++0'
UNH+19+INVOIC:D:01B:UN:EAN010'
BGM+380+353795+9'
DTM+171:2013-04-18'
LIN+1++8886419315339:VN'
IMD+++:::Razer Sphex - Full retai'
QTY+47:10'
PRI+AAA:89'
LIN+3++8886419330028:VN'
IMD+++:::Razer Deathadder RESPAWN'
QTY+47:10'
PRI+AAA:347'
LIN+4++8886419330127:VN'
IMD+++:::Razer Abyssus Gaming Mou'
QTY+47:1'
PRI+AAA:242,6'
LIN+5++8886419330660:VN'
IMD+++:::Razer Imperator 2012 Exp'
QTY+47:2'
PRI+AAA:447,5'
LIN+6++8886419311454:VN'
IMD+++:::Razer Lycosa gaming keyb'
QTY+47:2'
PRI+AAA:511,5'
LIN+7++8886419311614:VN'
IMD+++:::Razer Arctosa Silver Key'
QTY+47:2'
PRI+AAA:312'
LIN+10++8886419340317:VN'
IMD+++:::Anansi (MMO Keyboard)'
QTY+47:1'
PRI+AAA:639'
LIN+11++8886419330509:VN'
IMD+++:::Razer Naga - Molten Edit'
QTY+47:2'
PRI+AAA:479,5'
LIN+12++8886419330981:VN'
IMD+++:::Razer Naga Hex MOBA/ Act'
QTY+47:1'
PRI+AAA:479,5'
LIN+13++8886419312277:VN'
IMD+++:::Razer Carcharias Gaming'
QTY+47:2'
PRI+AAA:479,5'
LIN+14++8886419312628:VN'
IMD+++:::Razer Electra headset'
QTY+47:4'
PRI+AAA:383,5'
UNS+S'
MOA+139:790'
UNT+50+19'
UNZ+1+19'

It returns:

has an invalid token

Was it helpful?

Solution

At the very end, you have

last()

Positional indexers must be enclosed in square brackets.

So simply make it:

[last()]

OTHER TIPS

I solved it. Sorry Arran, you were totally right about [last()]. I just needed to put it in another place than suggested.

This is the solution:

/*[local-name()='EFACT_D96A_INVOIC' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='LINLoop1' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006'][last()]/*[local-name()='IMD_2' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='C273_2' and namespace-uri()='http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006']/*[local-name()='C27304' and namespace-uri()='']/text()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top