From Xojo Documentation


XMLDocument.ImportNode(foreignNode as XMLNode,[deep as Boolean]) As XMLNode

Supported for all project types and targets.

Copies a node from another XMLDocument into the current document.


If the optional parameter deep is True, ImportNode will import all the child nodes of foreignNode. After you import a node, you must then place it somewhere within the XMLDocument.


The following XML is stored in a constant called kXML:

 <?xml version="1.0" encoding="UTF-8"?>
 	<Team name="Seagulls">
 		<Player name="Bob" position="1B" />
 		<Player name="Tom" position="2B" />
 	<Team name="Pigeons">
 		<Player name="Bill" position="1B" />
 		<Player name="Tim" position="2B" />
 	<Team name="Crows">
 		<Player name="Ben" position="1B" />
 		<Player name="Ty" position="2B" />

To copy the first team into a new XML document:

Dim xml1 As New XmlDocument(kXml)
Dim xml2 As New XmlDocument

Dim root As XmlNode
root = xml2.AppendChild(xml2.CreateElement("League"))

Dim importNode As XmlNode
importNode = xml2.ImportNode(xml1.DocumentElement.FirstChild, True)


TextArea1.Text = xml2.ToString