Tuesday, July 6, 2021

Create XML with data from CustTrans table

 static void Create_XML(Args _args)
{
    XmlDocument doc;
    XmlElement  nodeXml;
    XmlElement  nodeTable;

    CustTrans   _custTrans;
    #define.filename(@"D:\Output\TEST_CREATE.xml")
    ;
    doc     = XmlDocument::newBlank();
    nodeXml = doc.createElement('CustomerVoucher');
    doc.appendChild(nodeXml);

    while select * from _custTrans
    where _custTrans.AccountNum == '10002'
    {
        nodeTable = doc.createElement('DocumentNumber');
        nodeXml.appendChild(nodeTable);
        nodeTable.appendChild(doc.createTextNode(
_custTrans.DocumentNum) );

        nodeTable = doc.createElement('VoucherNumber');
        nodeXml.appendChild(nodeTable);
        nodeTable.appendChild(doc.createTextNode(_custTrans.Voucher) );
    }
    doc.save(#filename);

}

No comments:

Post a Comment