Xmlnode_Object Clone Method

Creates a new XML node that is a clone of the current node.

…xmlnode_object.Clone(deep, xmldoc_object)

Prerequisites

None

Parameters

deep

A required Boolean numeric expression that determines if a deep or shallow copy of the node should be made.

xmldoc_object

An optional XmlDoc object that specifies the document tree that will contain the new node. If omitted, the clone will be a member of the same document tree as the original copied node.

Remarks

This method creates a copy of an existing node and also provides a means for copying nodes to a new document tree.

If the deep parameter is False, only the current node is copied. If the deep parameter is True, all nodes beneath the current node are copied recursively to create a new subtree.

Examples

Dim doc As XmlDoc 
Dim root As XmlNode
Dim elem1 As XmlNode
Dim
elem2 As XmlNode
Dim
sub1 As XmlNode
doc = New XmlDoc("my_doc")
root = doc.DocumentElement
elem1 = root.AddElementNode("section1", "Data for section 1")
sub1 = elem1.AddElementNode("section-a", "Sub-section data")
elem2 = root.AddElementNode("section2", "Data for section 2")
' Duplicate section-a under section 2
elem2.AppendChild(sub1.Clone(True))

See Also

XML Classes | xmldoc_object.CreateNode