IXMLDOMNode.cloneNode (C#)

banner art

Previous Next

IXMLDOMNode.cloneNode (C#)

The cloneNode method creates a new node that is an exact clone of this node.

Syntax

  IXMLDOMNode = IXMLDOMNode
  .cloneNode(
  bool bdeep
);

Parameters

bdeep

[in] bool that indicates whether to recursively clone all nodes that are descendants of this node. If true, create a clone of the complete tree below this node. If false, clone this node and its attributes only.

Return Values

Returns the newly created clone node.

Remarks

The cloned node has the same property values as this node for the following properties: nodeName, nodeValue, nodeType, parentNode, ownerDocument, and, if it is an element, the attributes property. The value of the clone's childNodes property depends on the setting of the flag parameter.

Example Code

The following example clones a node, and then appends the clone as a child of the top-level node.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMElement Root;
IXMLDOMNode currNode;
IXMLDOMNode MyNewNode;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Create a new playlist object.
    Playlist = Server.CreatePlaylist();

    // Load a playlist.
    Playlist.load("file://c:\\wmpub\\wmroot\\simple.wsx");

    // Retrieve the root element.
    Root = Playlist.documentElement;

    // Retrieve a child node and clone it.
    currNode = Root.childNodes[1];
    MyNewNode = currNode.cloneNode(true);

    // Append the clone as a child node of the root element.
    Root.appendChild(MyNewNode);
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

Requirements

Reference: Add references to Microsoft.WindowsMediaServices and interop_msxml.

Namespace: Microsoft.WindowsMediaServices.Interop, interop_msxml.

Assembly: Microsoft.WindowsMediaServices.dll, interop_msxml.dll.

Library: WMSServerTypeLib.dll, msxml.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next