Accessing Loaded EDI Data

Index

    Accessing Loaded EDI Data

    Developers can access all data from an EDI file that has been loaded with the EDIFileLoader using the EDILightWeightDocument returned after calling the Load() method. The EDILightWeightDocumentreturned enables access the EDI file. Because EDIFileLoader does not use any rules file, there is no validation on the EDI data. More importantly there is no proper hierarchy data conforming to the EDI implementation guides as you would find in the EDIValidator component. There is only one main loop containing all the parsed segments and elements that exist in the EDI file. This gives developers the flexibility to group this data however they please.

    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;
     
    // Set the source of EDI data, whether you are validating from an in-memory string or a file
    validator.EDISource = EDISource.File; // Or EDISource.DataString

    // Set the EDI file to load
    loader.EDIFile = “C:\\EDIFile.txt”;

    // Load the file
    EDILightWeightDocument doc = loader.Load();

    // Get the main loop. This loop contains the entire EDI document
    LightWeightLoop mainLoop = doc.Loop[0]; //the main loop

    // Get all segments
    Collection<LightWeightSegment> allSegments = mainLoop.Segments;
    in EDI File Loader
    Did this article answer your question?