XML-Read issue

John

Member
Hi Team,

I am not able to read XML data in to temp table using below code. Could someone help to identify where is the problem?

Code:
    DEFINE VARIABLE  SOutput AS LONGCHAR NO-UNDO.

    DEFINE TEMP-TABLE ttStatus NO-UNDO XML-NODE-NAME "Response"
      FIELD Msg       As CHAR          XML-NODE-NAME "Msg"
      FIELD MsgCode   As CHAR          XML-NODE-NAME "MsgCode".
      
    DEFINE DATASET ds   XML-NODE-NAME "Response" FOR  ttStatus.

    SOutput = '<ns0:Response xmlns:ns0="http://www.ddd.com/xx/ccc/xxx/Response.xsd" xmlns:SOAP-ENV="http://schemas.xmddd.org/fff/envelope/">
                              <ns0:Msg>ERROR: Code does not exist.  Please re-enter. - customer#1(cmAddr-test001)</ns0:Msg>
                              <ns0:MsgCode>ERROR</ns0:MsgCode>
                           </ns0:Response>'.
        
    DATASET ds:READ-XML("LONGCHAR",SOutput,"EMPTY",?,?,?,?).
          message temp-table ttStatus:has-records.

    FOR EACH ttStatus:
      message "Msg = " Msg  skip "MsgCode = " MsgCode view-as alert-box.
    END.
 

KrisM

Member
I think this should fix it.

Code:
DEFINE VARIABLE  SOutput AS LONGCHAR NO-UNDO.

    DEFINE TEMP-TABLE ttStatus NO-UNDO XML-NODE-NAME "Response"
      FIELD Msg       As CHAR          XML-NODE-NAME "Msg"
      FIELD MsgCode   As CHAR          XML-NODE-NAME "MsgCode".
    
    DEFINE DATASET ds   XML-NODE-NAME "Response" FOR  ttStatus.

    SOutput = '<ns0:Response xmlns:ns0="http://www.ddd.com/xx/ccc/xxx/Response.xsd" xmlns:SOAP-ENV="http://schemas.xmddd.org/fff/envelope/">
                              <ns0:Response>
                              <ns0:Msg>ERROR: Code does not exist.  Please re-enter. - customer#1(cmAddr-test001)</ns0:Msg>
                              <ns0:MsgCode>ERROR</ns0:MsgCode>
                              </ns0:Response>
                           </ns0:Response>'.
      
    DATASET ds:READ-XML("LONGCHAR",SOutput,"EMPTY",?,?,?,?).
          message temp-table ttStatus:has-records.

    FOR EACH ttStatus:
      message "Msg = " Msg  skip "MsgCode = " MsgCode view-as alert-box.
    END.
 

John

Member
I think this should fix it.

Code:
DEFINE VARIABLE  SOutput AS LONGCHAR NO-UNDO.

    DEFINE TEMP-TABLE ttStatus NO-UNDO XML-NODE-NAME "Response"
      FIELD Msg       As CHAR          XML-NODE-NAME "Msg"
      FIELD MsgCode   As CHAR          XML-NODE-NAME "MsgCode".
   
    DEFINE DATASET ds   XML-NODE-NAME "Response" FOR  ttStatus.

    SOutput = '<ns0:Response xmlns:ns0="http://www.ddd.com/xx/ccc/xxx/Response.xsd" xmlns:SOAP-ENV="http://schemas.xmddd.org/fff/envelope/">
                              <ns0:Response>
                              <ns0:Msg>ERROR: Code does not exist.  Please re-enter. - customer#1(cmAddr-test001)</ns0:Msg>
                              <ns0:MsgCode>ERROR</ns0:MsgCode>
                              </ns0:Response>
                           </ns0:Response>'.
     
    DATASET ds:READ-XML("LONGCHAR",SOutput,"EMPTY",?,?,?,?).
          message temp-table ttStatus:has-records.

    FOR EACH ttStatus:
      message "Msg = " Msg  skip "MsgCode = " MsgCode view-as alert-box.
    END.
Thanks for your reply.
I would be able to test this in next few hours but could you please tell me the reason for this change? Regards
 
Top