Corentin,
Ok, I see the issue, if you have two XML documents, and want to add one as a child of the other, you will need to use the XDOMImportNode to get them both using the same XDOM.
i.e.
*
$INCLUDE UNIVERSE.INCLUDE XML.H
*
dupFlag = 0
xmlDocument = "<root><child></child></root>"
* Open the original XML
ST = XDOMOpen(xmlDocument, XML.FROM.STRING, domHandle); GOSUB CHECK_ST
* Navigate to where you want to insert the other xml
xpathString = "/root/child"; nsMap = ""
ST = XDOMLocate(domHandle, xpathString, nsMap, nodeHandle); GOSUB CHECK_ST
* Open the other XML
to_add = "<subChild><subSubChild><subSubSubChild>Stuff to add</subSubSubChild></subSubChild></subChild>"
ST = XDOMOpen(to_add, XML.FROM.STRING, xml_to_add); GOSUB CHECK_ST
* Navigate to the first element
other_path = "/subChild"
ST = XDOMLocate(xml_to_add, other_path, nsMap, newNodeHandle); GOSUB CHECK_ST
* Import the new XML into the XDOM of the original XML
ST = XDOMImportNode(nodeHandle, newNodeHandle, XDOM.TRUE, newHandle); GOSUB CHECK_ST
* Add the new XML to the original XML
ST = XDOMAddChild(nodeHandle, xpathString, nsMap, newHandle, dupFlag); GOSUB CHECK_ST
doc = ""
ST = XDOMWrite(domHandle, doc, XML.TO.STRING)
CRT doc
STOP
CHECK_ST:
IF ST = XML.SUCCESS THEN
CRT "OK"
END ELSE
CRT "ISSUE WITH LAST COMMAND"
ST = XMLGetError(errorCode, errorMessage)
CRT errorCode
CRT errorMessage
END
RETURN
> RUN BP FORUM
OK
OK
OK
OK
OK
OK
<?xml version="1.1" encoding="UTF-8" standalone="no" ?>
<root>
<child>
<subChild>
<subSubChild>
<subSubSubChild>Stuff to add</subSubSubChild>
</subSubChild>
</subChild>
</child>
</root>
Mike Rajkowski
Rocket Software