Tuesday, November 6, 2012

Importing data from an XML file


class ReadXmlFile
{
}


public static void main(Args _args)
{
    XmlDocument doc;
    XmlNodeList data;
    XmlElement nodeTable;
    XmlElement nodeAccount;
    XmlElement nodeName;
    ;
    #define.filename(@'C:\Temp\accounts.xml')
    doc = XmlDocument::newFile(#filename);
    data = doc.selectNodes('//'+tableStr(MainAccount));
    nodeTable = data.nextNode();

    while (nodeTable)
    {
        nodeAccount = nodeTable.selectSingleNode(fieldStr(MainAccount, MainAccountId));
        nodeName = nodeTable.selectSingleNode(fieldStr(MainAccount, Name));
        info(strFmt("%1 - %2", nodeAccount.text(), nodeName.text()));
        nodeTable = data.nextNode();
    }
}

No comments: