Failed to create an xml node using a document-fragment Progress 4GL (Open Edge)

Status
Not open for further replies.
U

user3591371

Guest
I am developing in OpenEdge 11.1 and can successfully create an XML document from static data and connect to a third party API via SOAP.

I want to add an existing XML object to the new document I am creating, according to the Progress Help I should be able to add a Node of Type "DOCUMENT-FRAGMENT". When I do this my parent Node is just empty, and I do not get any error messages.

Is there some specific way of assigning the object to the new Node? I am trying with some static data (a string of valid XML) and have even thought of encoding the string in case it cannot handle the format.

Has anyone achieved this before now, what am I doing wrong?

DEFINE VARIABLE hDoc AS HANDLE NO-UNDO.
DEFINE VARIABLE hRoot AS HANDLE NO-UNDO.
DEFINE VARIABLE hNode AS HANDLE NO-UNDO.
DEFINE VARIABLE hRow AS HANDLE NO-UNDO.

DEFINE VARIABLE clData AS LONGCHAR NO-UNDO.

CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hNode.
CREATE X-NODEREF hRow.

hDoc:CREATE-NODE(hRoot,"NewDocument","ELEMENT").
hDoc:APPEND-CHILD(hRoot).
hRoot:SET-ATTRIBUTE("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance").


/* NewDocument Product data */
hDoc:CREATE-NODE(hNode,"Product","ELEMENT").
hRoot:APPEND-CHILD(hNode).
/* Product Detail */
hDoc:CREATE-NODE(hRow,"","DOCUMENT-FRAGMENT").
hNode:APPEND-CHILD(hRow).
hRow:NODE-VALUE = '<Available>10</Available><ProductCode>ABC</ProductCode>~
<ProductName>Special</ProductName><ValidFrom>2014-05-02T08:15:00</ValidFrom>~
<ValidTo>2014-05-02T12:45:00</ValidTo><Comments xsi:nil="true" />~
<Price>9.00</Price><PriceID>123456789</PriceID>'.

hDoc:SAVE("LONGCHAR", clData).
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hRow.
DELETE OBJECT hNode.

OUTPUT TO "test.log" APPEND.
PUT UNFORMATTED "Start request... " SKIP.
OUTPUT CLOSE.
COPY-LOB clData TO FILE "test.log" APPEND.

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