The following code example creates a static temp-table, then writes the data to an XML file:

DEFINE TEMP-TABLE ttSample NO-UNDO XML-NODE-NAME "XMLSample"
   FIELD samplenum AS INT64 XML-NODE-TYPE "ATTRIBUTE"
   FIELD myfield AS CHARACTER XML-NODE-NAME "MyField"
   FIELD data AS CHARACTER
   INDEX samplenum IS PRIMARY UNIQUE samplenum.
   
DEFINE VARIABLE iCount AS INT64 NO-UNDO.

DO iCount = 1 TO 3:
   CREATE ttSample.
   ASSIGN ttSample.samplenum = icount
          ttSample.myfield   = "xxx"
          ttSample.data      = "This is record number " + STRING(iCount).
END.

TEMP-TABLE ttSample:WRITE-XML("FILE",
                              "C:\temp\logs\sample.xml",
                              YES,
                              ?,
                              ?,
                              NO,
                              NO,
                              ?,
                              YES). 
This is the resulting output from running the code:
<?xml version="1.0"?>
<XMLSample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <XMLSampleRow samplenum="1">
    <MyField>xxx</MyField>
    <data>This is record number 1</data>
  </XMLSampleRow>
  <XMLSampleRow samplenum="2">
    <MyField>xxx</MyField>
    <data>This is record number 2</data>
  </XMLSampleRow>
  <XMLSampleRow samplenum="3">
    <MyField>xxx</MyField>
    <data>This is record number 3</data>
  </XMLSampleRow>
</XMLSample>

The first XML element written for each record in the temp-table contains the node name with "Row" appended to it. For example, in the XML above, the element name is XMLSampleRow. This behavior cannot be changed.

It is also not possible to change the element names to something different for each individual record output. All records use the same element names.