Write-XML is not appending XML into an existing document - Forum - OpenEdge Development - Progress Community

Write-XML is not appending XML into an existing document

 Forum

Write-XML is not appending XML into an existing document

This question is answered

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

Verified Answer
  • 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
  • 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
  • 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.

  • 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 */