[Stackoverflow] [Progress OpenEdge ABL] How to check XML file if node exists and retrieve value in Progress4GL

Status
Not open for further replies.
J

Joseph Betts

Guest
Hello Progress4GL Developers,

I have the following XML response stored in a longchar variable called cBody after making a successful SOAP call to UPS:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<trk:TrackResponse xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trk="http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0"><common:Response xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<common:ResponseStatus>
<common:Code>1</common:Code>
<common:Description>Success</common:Description>
</common:ResponseStatus>
<common:TransactionReference/>
</common:Response>
<trk:Shipment>
<trk:InquiryNumber>
<trk:Code>01</trk:Code>
<trk:Description>ShipmentIdentificationNumber</trk:Description>
<trk:Value>MYTRACKERNUMBER</trk:Value>
</trk:InquiryNumber>
...


I now store this as as a X-DOCUMENT using the following line of code:

hDoc:LOAD("longchar",cBody2,FALSE).


Now I would like to check if my response has a tracking number, and if it does I would like to store the tracking number as a variable. It appears that this is possible: OpenEdge 11.7 Documentation

However this is what I have so far, and it doesn't seem to work. Nothing is outputted but no runtime errors:

....
hDoc:LOAD("longchar",cBody,FALSE).

DEFINE variable hNodeRef as HANDLE NO-UNDO.
CREATE X-NODEREF hNodeRef.

hDoc:GET-DOCUMENT-ELEMENT(hNodeRef).
IF hNodeRef:NAME = "trk:value" THEN
message hNoderef:GET-ATTRIBUTE("id") hNoderef:ATTRIBUTE-NAMES.
....

Continue reading...
 
Status
Not open for further replies.
Top