Parse XML File

This sample parses an XML file and inserts new orders into the Northwind database. You can get sample Northwind databases here.

This Linx Solution uses the Xml, Database, File and Utilities plugins.


Download

ParseXMLFile.zip


To run the sample

  1. Open the ParseXMLFile solution.
  2. Click on the Settings button.
  3. On the Settings tab change the values of the Settings to suit your environment (if you need help with the database connection string, have a look at this help topic).
  4. Open the sample Process you want to run from the Solution Explorer pane on the left.
  5. Click the Debug or Run buttons to run the Process.


How it works

There are three processes:

  • ImportOrders
    Parses the XML file using the XmlReader function and inserts the records into the database.
  • ExportImportedOrders
    Writes the imported orders to an XML file using the XmlWriter function to check that the import succeeded.
  • DeleteImportedOrders
    Deletes the imported orders.


Create your own Solution

Steps:

  1. Create a Solution

  2. Rename your Solution, Project and Process

  3. Add Settings to the Solution

  4. Add Plugins

  5. Build a process for ImportOrders
    1. Add an XmlReader function

    2. Debug the ImportOrders process

    3. Loop through the XmlReader results

    4. Insert each Order into the database

    5. Loop through each order's Order Details

    6. Insert the Order Details into the database

    7. Debug your final process
  6. Build a process for ExportImportedOrders
    1. Add a process

    2. Add a CustomType

    3. Add a List to the ExportImportedOrders process

    4. Read from the database

    5. Add SQL output to a Custom Type

    6. Add Custom Types to a List

    7. Create the XML structure

    8. Write an XML structure to a file
  7. Build a process for DeleteImportedOrders
    1. Add a Process

    2. Delete from the database
  8. Build an automated test process: TestDemo
    1. Call an internal process from within a process

    2. Read the imported orders

    3. Compare the Expected Results to the Actual Results

    4. Add the XmlPeek function

For a detailed description of these steps, go here.


Also see

Linx Community: Reformat XML using XSLT