Reputation: 221
i have 835 EDI file,
ISA*00* *00* *33*83876 *ZZ*B00482000 *190128*1100*^*00501*000000001*0*T*:~
ST*835*000000001~
BPR*H*0*C*NON************20190128~
TRN*1*PK673981180*141138499245*PS0087726~
REF*EV*B048499999800~
REF*F2*1083~
DTM*405*20190128~
how shall i extract ST value i.e. 000000001 and so on,
i tried to convert my edi file into XML format using SMOOKS first and then retrieving the data via parent and child node.
public static void main(String[] args) throws SmooksException, Exception {
String modelURI = "urn:org.milyn.edi.unedifact:d99a-mapping:1.4";
UNEdifactInterchangeParser parser = new UNEdifactInterchangeParser();
// parser.addMappingModels(modelURI, new URI("/"));
parser.setFeature(EDIParser.FEATURE_IGNORE_NEWLINES, true);
SAXHandler handler = new SAXHandler();
parser.setContentHandler(handler);
parser.parse(new InputSource(new java.io.FileInputStream(
"myEDIfile.edi")));
Document doc = handler.getDocument();
// Here you have your document
new XMLOutputter(Format.getPrettyFormat()).output(doc, System.out);
}
Caused by: org.xml.sax.SAXException: Unknown/Unexpected UN/EDIFACT control block segment code 'ISA'.
if anyone can help me with the possible solution it would be great. Thanks in advance..
Upvotes: 0
Views: 3838
Reputation: 378
Take a look at edi-835-parser. It is a Python Library I wrote specifically for parsing the EDI 835 file type and would be more 'out-of-the-box' than using x12-parser.
GitHub Repo: https://github.com/keironstoddart/edi-835-parser.
Upvotes: 0
Reputation: 211
You are trying to parse an X12 835 by using EDIFACT parser.
Instead of UNEdifactInterchangeParser you need to use the corresponding X12 parser.
Upvotes: 2
Reputation: 5859
Take a look at the X12 parser - it is commonly used for such files:
Documentation: https://media.readthedocs.org/pdf/x12-parser/latest/x12-parser.pdf
GitHub Repo: https://github.com/imsweb/x12-parser
Upvotes: 0