1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to read a xml file and export an item using progress 4gl

Discussão em 'StackOverflow' iniciado por fdantas, Agosto 9, 2018.

  1. fdantas

    fdantas Administrator Moderador

    When I execute the following code to read a xml file in progress language, I need only 3 items from that xml file but this code can not read it.

    The code is:


    DEFINE VARIABLE hDoc AS HANDLE NO-UNDO.
    DEFINE VARIABLE hRoot AS HANDLE NO-UNDO.
    DEFINE VARIABLE hTable AS HANDLE NO-UNDO.
    DEFINE VARIABLE hField AS HANDLE NO-UNDO.
    DEFINE VARIABLE hText AS HANDLE NO-UNDO.
    DEFINE VARIABLE hBuf AS HANDLE NO-UNDO.
    DEFINE VARIABLE hDBFld AS HANDLE NO-UNDO.
    DEFINE VARIABLE ix AS INTEGER NO-UNDO.
    DEFINE VARIABLE jx AS INTEGER NO-UNDO.
    DEFINE VARIABLE returnCode AS DECIMAL NO-UNDO.
    DEFINE VARIABLE returnMessage AS CHARACTER NO-UNDO.
    DEFINE VARIABLE bravoId AS CHAR NO-UNDO.

    CREATE X-DOCUMENT hDoc.
    CREATE X-NODEREF hRoot.
    CREATE X-NODEREF hTable.
    CREATE X-NODEREF hField.
    CREATE X-NODEREF hText.


    /* Read in the file created in i-outcus.p */
    hDoc:LOAD("file", "C:\user53.xml", TRUE).
    hDoc:GET-DOCUMENT-ELEMENT(hRoot).

    REPEAT ix = 1 TO hRoot:NUM-CHILDREN:
    hRoot:GET-CHILD(hTable, ix).

    /* Get the fields given as attributes */

    string(returnCode) = hTable:GET-NODE("returnCode").
    returnMessage = hTable:GET-NODE("returnMessage").
    bravoId = hTable:GET-NODE("Id").
    REPEAT jx = 1 TO hTable:NUM-CHILDREN:
    hTable:GET-CHILD(hField, jx).
    hField:GET-CHILD(hText, 1).
    hDBFld:BUFFER-VALUE = hTEXT:NODE-VALUE.
    END.
    END.

    DELETE OBJECT hDoc.
    DELETE OBJECT hRoot.
    DELETE OBJECT hTable.
    DELETE OBJECT hField.
    DELETE OBJECT hText.

    FOR EACH v:
    DISPLAY ' ReturnCode: ' + STRING(returnCode) + ' - ReturnMessage: ' + returnMessage + ' id: ' + id.
    END.

    The xml file:


    <?xml version="1.0" encoding="utf-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <ns1:ImportProfilesResponse xmlns:ns1="http://host.bs.com/common/webservice/ProfileManagement/">
    <returnCode>-996</returnCode>
    <returnMessage>Invalid SOAP Request Object - 112(FISCAL_CODE);</returnMessage>
    <id>0000</id>
    </ns1:ImportProfilesResponse>
    </soapenv:Body>
    </soapenv:Envelope>

    Continue reading...

Compartilhe esta Página