XML API: How to load text into an XmlCode, then append to another node

gatsby0121gatsby0121 Posts: 11Member
I'm loading using LoadXMLNodeFromText to create an xmlnode from a string, then add it to another element using XML Dom Mgt.AddElement.

However, when I write the results to a text string, the text that I loaded into the XmlNode is not there. This is my procedure, is there something I'm missing?
procedure CreateBody(var pSoapEnvelope: XmlNode; var pSoapBody: XmlNode; pVersion: Option "1.1","1.2"; var reqText: Text);
        lSoapDataNode: XmlNode;
        textString: Text;
        if pVersion = pVersion::"1.1" then
            XMLDOMMgt.AddElement(pSoapEnvelope, 'Body', '', SoapNS11, pSoapBody)
            XMLDOMMgt.AddElement(pSoapEnvelope, 'Body', '', SoapNS12, pSoapBody);
        XMLDomMgt.LoadXMLNodeFromText(reqText, lSoapDataNode);
        XMLDOMMgt.AddElementWithPrefix(pSoapBody, 'CV3Data', '', SoapPrefix, 'SoapNamespaceTxt', pSoapBody); //xx01
        XMLDOMMgt.AddElement(pSoapBody, 'data', reqText, '', lSoapDataNode);


  • gatsby0121gatsby0121 Posts: 11Member
    I think there was a bug in the xml dom mgt c/al to al rewrite by Divesh Bora, where the addelement method was adding the nodetext to the new node if it was blank. I changed the check to <> instead and it's now working.
  • AlexDenAlexDen Posts: 9Member
    edited 2018-11-08

    I think you should use AddElementToNode() instead of AddElement() in this case.
    AddElement() creates new node and you lose result of LoadXMLNodeFromText().
    XMLDOMMgt.AddElementWithPrefix(pSoapBody, 'CV3Data', '', SoapPrefix, 'SoapNamespaceTxt', pSoapBody);
    XMLDomMgt.LoadXMLNodeFromText(reqText, lSoapDataNode);
Sign In or Register to comment.