Import XML files

rashi.kaushikrashi.kaushik Member Posts: 52
edited 2007-08-15 in Dynamics AX
Hi

I need to import the data from a XML file into one of my tables in AX 4.0.
Is there any standard way to accomplish this?

Appreciate your help

Regards
Rashi

Comments

  • lingdanglfwlingdanglfw Member Posts: 1
    you need write a class or job to import the data:
    xml sample: CM_GC_FGS.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    - <CONFIRM_MSG_GC>
    <PROID>I</PROID>
    <OPERMODE>GC</OPERMODE>
    <MESLOTID>AAA0649011AA000</MESLOTID>
    <HISTSEQ>0</HISTSEQ>
    <MESGTYPE>S</MESGTYPE>
    <MESGID>002</MESGID>
    <MESGDESC>All proccess was succesfully done</MESGDESC>
    <PROCTIME>20070514161906</PROCTIME>
    <RESV1 />
    <RESV2 />
    <RESV3 />
    <RESV4 />
    <ACTIONFLAG />
    </CONFIRM_MSG_GC>


    import job:
    static void ReadXMLFile(Args _args)
    {
    XMLDocument oXMLDoc;
    XMLNode oXMLNode;
    XMLNode rootNode, bodyNode, bodyNode1, bodyNode2, bodyNode3;
    XMLNodeList bodyLines, bodyLines1, bodyLines2, bodyLines3, bodyLines4;
    FileName Str_FileName;
    Exception exception;
    Container Con_infolog;
    Int Int_ConLen;
    MyTable myTBL;
    ;

    Con_infolog = infolog.copy(1,infolog.line());
    Int_ConLen = conlen(Con_infolog);
    ttsbegin;
    try
    {
    Str_FileName = "c:\\CM_GC_FGS.xml";
    oXMLDoc = new XMLDocument();
    oXMLDoc.async(FALSE);

    oXMLDoc.load(Str_FileName);

    rootNode = oXMLDoc.documentElement();

    myTBL.PROID = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/PROID').text();
    myTBL.OPERMODE = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/OPERMODE').text();
    myTBL.MESLOTID = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESLOTID').text();
    myTBL.HISTSEQ = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/HISTSEQ').text();
    myTBL.MESGTYPE = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGTYPE').text();
    myTBL.MESGID = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGID').text();
    myTBL.MESGDESC = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGDESC').text();
    myTBL.PROCTIME = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/PROCTIME').text();
    myTBL.RESV1 = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV1').text();
    myTBL.RESV2 = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV2').text();
    myTBL.RESV3 = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV3').text();
    myTBL.RESV4 = oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV4').text();
    mtTBL.doInsert();
    /*
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/PROID').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/OPERMODE').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESLOTID').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/HISTSEQ').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGTYPE').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGID').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/MESGDESC').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/PROCTIME').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV1').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV2').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV3').text();
    print oXMLDoc.selectSingleNode('//CONFIRM_MSG_GC/RESV4').text();
    */
    }
    catch (Exception::Info)
    {
    ttsabort;
    exception = Exception::Info;
    Con_infolog = infolog.copy(1,infolog.line());
    }
    ttscommit;
    pause;

    }
Sign In or Register to comment.