How to convert EDI to XML
What is XML?
Extensible Markup Language (XML) is a markup language based on texts which is derived from SGML (Standard Generalized Markup Language). These tags are used for identifying the data and are basically used to organize and store information and data.
What is the need of converting EDI to XML?
If we are able to convert EDI X12 to XML language, then it gives us an extra benefit over other developers who are involved in the EDI projects. This will eventually help the IT department to leverage the EDI2XML in their integrated EDI projects.
How to convert X12 EDI into XML language?
Before getting into conversion you need to understand raw EDI data.
For a sample, let us use this EDI 831 transaction file from X12 transaction set. We include this file (named 831.x12) in the “Convert to XML” folder.
ISA:00: :00: :01:1515151515 :01:515151
This below example will tell you how an EDI file can be converted into a XML file. The source code in the VB.NET which is used for converting EDI files into a XML file which is built with the function of EDIdEv framework EDI (FREDI). So how to convert EDI into XML? The basic and simple algorithm to convert is
- Instantiate an Electronic Data Interchange (EDI) document (it should be in the form of FREDI component)
- Load on the appropriate and suitable SEF file, that is essentially a scheme of any transaction set. This is because the FREDI do know how to have parsed an EDI file correctly and correspondingly.
<?xml version=”1.0″ encoding=”utf-8″?>
…. And so on. This is the code behind this logic.
- Load the EDI file which is to be converted into an EDI document object.
- This EDI document should be saved as an XML output.
“Private Sub cmdConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConvert.Click
‘Recommended only for short EDI files
Dim oEdiDoc As ediDocument
Dim spath As String
cmdConvert.Enabled = False
Me.Cursor = Cursors.WaitCursor
spath = AppDomain.CurrentDomain.BaseDirectory
oEdiDoc.Set(oEdiDoc, New ediDocument) ‘instantiate EDI document ‘oEdiDoc = New ediDocument
‘Load Schema for transaction set 850 4010
oEdiDoc.LoadSchema(spath & “850_X12-4010.SEF”, SchemaTypeIDConstants.Schema_Standard_Exchange_Format)
‘Load 850 4010 EDI File
oEdiDoc.LoadEdi(spath & “850.X12”)
‘Save to XML format
oEdiDoc.Save(spath & “850_X12_XmlOutput.XML”, OutputTypeIDConstants.OutputType_XML)
‘Display XML string on screen
Me.Cursor = Cursors.Default
MsgBox(“Done. XML file = ” & sXmlFile)
oEdiDoc.Dispose() ‘oEdiDoc = Nothing
“After using this code the suitable output of XML comes out. The partial XML File output is given below:
If you are looking for the best EDI Consulting Company then, you can visit our websites and we can convert EDI to XML for you.