Article: EDI File Loader – Converting To XML

Index

Converting To XML

EDIFileLoader allows developers to load EDI files and convert them to XML

Example

// Create a new instance of EDIFileLoader

EDIFileLoader loader = new EDIFileLoader();

// Set the type of EDI file that you are about the load

loader.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are loading from an in-memory string or a file
loader.EDISource = EDISource.File; // Or EDISource.DataString
 
// Set the EDI file path to load
loader.EDIFile = “C:\EDIFile.txt;
 
// load the data
EDILightWeightDocument loadedDocument = loader.Load();
 
//Convert to XML
XmlDocument xmlDoc = loadedDocument.ToXml();    
 
//Or save to a file
loadedDocument.ToXml(“C:\EDIFile.xml);
 

Since there are no rules required EDIFileLoader only parses and loads all the segments in one loop. It does not group the segments into a loop hierarchy structure.

Related Articles

Main Categories