Compartilhar via


cloneNode Method (Compact 2013)

3/26/2014

Clones a new node.

Syntax

var objXMLDOMNode = oXMLDOMNode.cloneNode(deep);
HRESULT cloneNode(
  VARIANT_BOOL deep,
  IXMLDOMNode** cloneRoot
);

Parameters

Script

  • deep
    Boolean. Flag 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.

C/C++

  • deep
    [in] Flag 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.
  • cloneRoot
    [out, retval] Newly created clone node.

Return Value

Script

Object. Returns the newly created clone node.

C/C++

  • S_OK
    Value returned if successful.
  • E_INVALIDARG
    Value returned if cloneRoot is Null.

Remarks

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

Note

If the node is the DOMDocument node, it is safer to clone the document using the save method, as follows.
doc.save(doc2);

This method applies to the following objects and interfaces:

IXMLDOMAttribute, IXMLDOMCDATASection, IXMLDOMCharacterData, IXMLDOMComment, DOMDocument, IXMLDOMDocumentFragment, IXMLDOMDocumentType, IXMLDOMElement, IXMLDOMEntity, IXMLDOMEntityReference, IXMLDOMNode, IXMLDOMNotation, IXMLDOMProcessingInstruction, IXMLDOMText, and IXTLRuntime.

Requirements

Header

msxml2.h,
msxml2.idl

Library

uuid.lib

See Also

Reference

XML DOM Methods
nodeValue Property
nodeType Property
parentNode Property
ownerDocument Property
attributes Property
childNodes Property