You can export data from tables to XML by using XMLPorts. But you can also use XMLPorts to export data from temporary tables.
The principle is to set the Temporary property on the table line and then create a function in XMLPort that inserts all the data into the temporary record.
I will start with creating a XMLPort to the Item table. I have only chosen two fields, “No.” and Description.
In order for the XMLPort to be temporary we have to set the following setting
Lets create the function that inserts the data into the temporary table. Note that the record that I inserts to is the same record name on the XMLPort line.
Once this is done I’ll create a test function that builds our temporary data, sends the data to the temporary XMLPort and then the export function on it.
PROCEDURE ExportTempRecordsToXMLFile@1000000002(); VAR TemporaryItemXMLPort@1000000003 : XMLport 69790; TempItem@1000000004 : TEMPORARY Record 27; TestFile@1000000002 : File; Outstream@1000000001 : OutStream; FileName@1000000000 : Text; BEGIN //Builds data in temporary records and uses a XMLport with the //temporary property to export the temporary records as XML //Build the temporary records //TempItem is declared as temporary TempItem.INIT; TempItem."No." := '1'; TempItem.Description := 'Test1'; TempItem.INSERT; TempItem.INIT; TempItem."No." := '2'; TempItem.Description := 'Test2'; TempItem.INSERT; //Create a stream to the destination file FileName := 'C:\temp\TESTXML.txt'; TestFile.CREATE(FileName); TestFile.CREATEOUTSTREAM(Outstream); //XMLPort part TemporaryItemXMLPort.InsertTemporaryRecords(TempItem); TemporaryItemXMLPort.SETDESTINATION(Outstream); TemporaryItemXMLPort.EXPORT; TestFile.CLOSE; HYPERLINK(FileName); //To open the file when it is done END;
Once done the result is this