class My_XMLCreate
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
XmlDocument xdoc;
XmlElement xElement;
XmlElement xTable, xNodeAccount, xNodeName;
MainAccount mainAccount;
#define.filename(@'C:\Temp\accounts.xml');
xdoc = XmlDocument::newBlank();
xElement =xdoc.createElement('xml');
xdoc.appendChild(xElement);
while select RecId, mainAccountId, Name from mainAccount
{
xTable = xdoc.createElement(tableStr(MainAccount));
xTable.setAttribute(fieldStr(MainAccount, RecId), int642Str(mainAccount.RecId));
xElement.appendChild(xTable);
xNodeAccount = xdoc.createElement(fieldStr(MainAccount, MainAccountId));
xNodeAccount.appendChild(xdoc.createTextNode(MainAccount.MainAccountId));
xTable.appendChild(xNodeAccount);
xNodeName = xdoc.createElement(fieldStr(MainAccount, Name));
xNodeName.appendChild(xdoc.createTextNode(mainAccount.Name));
xTable.appendChild(xNodeName);
}
xdoc.save(#filename);
Info(strFmt("File %1 created", #filename));
}
}
No comments:
Post a Comment