Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Writing XML from a temp-table, temp-table buffers, or a ProDataSet : Writing temp-table data to XML
 

Writing temp-table data to XML

Having taken a tour through several scenarios for reading XML data, examples of writing XML data will be mostly familiar. If you wish to experiment with these code samples, the best way to examine your results is to open the XML data files and see how your changes affected the XML.
The following code example creates a static temp-table, copies a subset of Customer records to it, then serializes the data to an XML file:
/* pi-tfx-write-3.p */
/* Populates a temp-table with a subset of Customer records and writes it
to an XML file. */

{pi-tfx-parameterVarDefs.i}
{pi-tfx-writeSetup-3.i}

DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO.

FOR EACH Customer NO-LOCK WHERE Customer.CustNum < 4:
  CREATE ttCustomer.
  BUFFER-COPY Customer TO ttCustomer.
END.

ASSIGN
  cTargetType     = "FILE"
  cFile           = "ttCustomer.xml"
  lFormatted      = YES
  cEncoding       = ?
  cSchemaLocation = ?
  lWriteSchema    = NO
  lMinSchema      = NO.

lReturn = TEMP-TABLE ttCustomer:WRITE-XML(cTargetType, cFile, lFormatted,
  cEncoding, cSchemaLocation, lWriteSchema, lMinSchema).