Karen Wilson

Karen Wilson

  • NA
  • 6
  • 1.9k

Parse an EDIFACT message to find a certain segment

Nov 13 2019 1:53 PM
Hello, I am trying to parse out the all the LOC segments and populate an array with the 2nd and 3rd element of each segment.
 
Note: the ‘+’ is an element delimiter
 
I understand to parse a string into an array I can use something like this:
 
string[] Arr = str.Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
 
But when trying to parse a message, how do I only find a certain segment?
 
UNA:+.? '
UNB+UNOC:3+2021000969+4441963198+180525:1225+3VAL2MJV6EH9IX+KMSV7HMD+CUSDECU-IE++1++1'
UNH+EDIFACT+CUSDEC:D:96B:UN:145050'
BGM+ZEM:::EX+09SEE7JPUV5HC06IC6+Z'
LOC+17+IT044100'
LOC+18+SOL'
LOC+35+SE'
LOC+36+TZ'
LOC+116+SE003033'
DTM+9:20090527:102'
DTM+268:20090626:102'
DTM+182:20090527:102'

Answers (1)