我有 835 EDI 文件,
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~
我该如何提取ST值,即000000001等等,
我尝试首先使用 SMOOKS 将我的 edi 文件转换为 XML 格式,然后通过父节点和子节点检索数据。
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);
}
但我收到错误
由以下原因引起:org.xml.sax.SAXException:未知/意外的 UN/EDIFACT 控制 block 段代码“ISA”。
如果有人可以帮助我找到可能的解决方案,那就太好了。 提前致谢..
最佳答案
您正在尝试使用 EDIFACT 解析器解析 X12 835。
您需要使用相应的 X12 解析器,而不是 UNEdifactInterchangeParser。
关于java - 我该如何从 835 EDI 文件中提取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54577983/