With the XML Buffer integrated in Business Central and with the help of streams we can import pretty easily any XML file and process data as you would do in any table.

Variables


Create a procedure with the following variables:

  • We need a Blob field in order to save our data. So any Blob field of a custom table will do, remember to make it temporary.
  • A record for the XML Buffer, also temporary.
  • An Instream variable
  • A text variable


Code


Now that we have all the variables it´s time to make them work together:

  • CreateInstream function allows the data to travel to our blob field when uploading the XML file. So with the Miblob.CreateInstream we allow it.
  • Uploadig the XML file is pretty easy with the function ‘UploadInstoStream’.
  • Finally the LoadFromStream function gets our data to our XML temporary buffer.
  • If we want to see the data uploaded we can create a page to the XML Buffer table and see the result. Now you just need to filter the table as you would do with any other table and process the data accordingly to your needs.


This is an example of how the import looks like in Business Central.


Hope you find it useful.

How To Import XML Files Easily To Business Central

Post navigation