System.Xml.XmlNode.Clone Method

Creates a duplicate of this node.

Syntax

public virtual XmlNode Clone ()

Returns

The cloned node.

Remarks

Cloning an System.Xml.XmlElement copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes. This method recursively clones the node and the subtree underneath it.

Clone is equivalent to calling CloneNode(true).

The following table describes the specific behavior for each System.Xml.XmlNodeType.

Attribute

Clones the attribute node, including child nodes.

CData

Clones the CData node, including its data content.

Comment

Clones the comment node, including its text content.

Document

Clones the document node, including any child nodes.

DocumentFragment

Clones the document fragment node, including any child nodes.

DocumentType

Clones the document type node.

Element

Clones the element node, its attributes, and any child nodes.

Entity

Entity nodes cannot be cloned.

EntityReference

Clones the entity reference node. The replacement text is not included.

Notation

Notation nodes cannot be cloned.

ProcessingInstruction

Clones the processing instruction node, including its target and data.

SignificantWhitespace

Clones the significant white space node, including its data value.

Text

Clones the text node, including its data value.

Whitespace

Clones the white space node, including its data value.

XmlDeclaration

Clones the XmlDeclaration node, including its data value.

All other node types.

These node types cannot be cloned.

This method is a Microsoft extension to the Document Object Model (DOM).

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0