Hello,
i don't have your tables and/or fields in my system, so i'm not able to reproduce exactly your scenario. But i tried to write a similar job for my system, and for me it works as expected:
static void Job1(Args _args)
{
XmlDocument xmlDoc;
XmlElement xmlRecord1, xmlRecord, xmlField;
CustGroup custGroup;
counter u;
#Tax_AT
xmlDoc = XmlDocument::newBlank(#encoding);
xmlRecord1 = xmlDoc.createElement("HANG_HOA_DONS");
while select custGroup
{
xmlRecord = xmlDoc.createElement("InvoiceItems");
for (u=1; u<=5; u++)
{
xmlField = xmlDoc.createElement("Field_"+int2str(u));
xmlField.innerText("Some value");
// Append the field as a child node to the record
xmlRecord.appendChild(xmlField);
}
// Add the record as a child node to the root
xmlRecord1.appendChild(xmlRecord);
}
xmlDoc.appendChild(xmlRecord1);
info(xmlDoc.xml());
}
The created XML looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<HANG_HOA_DONS>
<InvoiceItems>
<Field_1>Some value</Field_1>
<Field_2>Some value</Field_2>
<Field_3>Some value</Field_3>
<Field_4>Some value</Field_4>
<Field_5>Some value</Field_5>
</InvoiceItems>
<InvoiceItems>
<Field_1>Some value</Field_1>
<Field_2>Some value</Field_2>
<Field_3>Some value</Field_3>
<Field_4>Some value</Field_4>
<Field_5>Some value</Field_5>
</InvoiceItems>
<InvoiceItems>
<Field_1>Some value</Field_1>
<Field_2>Some value</Field_2>
<Field_3>Some value</Field_3>
<Field_4>Some value</Field_4>
<Field_5>Some value</Field_5>
</InvoiceItems>
</HANG_HOA_DONS>
Maybe you will show us, how your XML should look like by posting an example?