Write-XML is not appending XML into an existing document

Posted by christian.bryan@capita.co.uk on 19-Jan-2018 10:53

Hi 

Not sure whether i am doing this right as i couldn't find good documentation.

But i have an existing XML document created using the DOM parser and i was hoping the write-xml function could write into this e.g.

TEMP-TABLE tt-getTenancyDetails:WRITE-XML("handle", lv-TenanciesNode, FALSE,  ?, ?, FALSE, FALSE).

Where lv-TenanciesNode is a DOM X-NODEREF.

However it doesn't write the data into the node but there is no error is this because WRITE-XML is the SAX parser?

WIill i have to write the XML into a longchar and then load that into a DOM X-DOC and then use that instead to insert the xml into my DOM tree?

Thanks

Posted by christian.bryan@capita.co.uk on 06-Feb-2018 03:06

Hi

Robin is correct.

The documentation is not very clear but you need to create a node in our document to attach the contents of the WRITE-XML to and then append that document to your already created document e.g.

/* o-doc is my existing XML document */

/* lv-TempNode is created here as a node of o-Doc */

/* Parent node created here as a child node of o-Doc. */

/* This the temp store from the Import-node data */

o-doc:CREATE-NODE(lv-TempNode,"Temp","Element").

DATASET HS_myDataSet:WRITE-XML("HANDLE", lv-TempNode, FALSE,  ?, ?, FALSE, FALSE).

/* Append the temp node that has the DATASET to our parent node */

lv-ParentNode:APPEND-CHILD(lv-TempTenancyNode).    

/* The dataset is now in o-Doc as a child of lv-ParentNode */

All Replies

Posted by Rick Terrell on 19-Jan-2018 11:12

Read the existing XML into the true. Add what you need at the appropriate place. Write it out. 

Rick Terrell 
Principle Consultant, Professional Services 
Progress

Sent from my iPhone

Posted by Robin Brown on 19-Jan-2018 11:15

WRITE-XML will not append to existing data in the X-NODEREF.  It will delete the existing data and then write the temp-table data to the X-NODEREF.  You should be able to use WRITE-XML to an X-NODEREF, then insert it into your DOM tree.  If that is not the case, then I'd call it a bug.

Posted by christian.bryan@capita.co.uk on 06-Feb-2018 03:06

Hi

Robin is correct.

The documentation is not very clear but you need to create a node in our document to attach the contents of the WRITE-XML to and then append that document to your already created document e.g.

/* o-doc is my existing XML document */

/* lv-TempNode is created here as a node of o-Doc */

/* Parent node created here as a child node of o-Doc. */

/* This the temp store from the Import-node data */

o-doc:CREATE-NODE(lv-TempNode,"Temp","Element").

DATASET HS_myDataSet:WRITE-XML("HANDLE", lv-TempNode, FALSE,  ?, ?, FALSE, FALSE).

/* Append the temp node that has the DATASET to our parent node */

lv-ParentNode:APPEND-CHILD(lv-TempTenancyNode).    

/* The dataset is now in o-Doc as a child of lv-ParentNode */

This thread is closed