Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
clone Method
Collapse the table of content
Expand the table of content

clone Method

Clones a copy of the current IXMLDOMSelection, with the same position and context.

var NewObjXMLDOMSelection = objXMLDOMSelection.clone();


// Create a DOMDocument2 object and load some XML.
xmldoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
if (xmldoc.parseError.errorCode != 0) {
   var myErr = xmldoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   // Create an XMLDOMSelection object from selected nodes.
   xpath = xmldoc.selectNodes("root/elem1");
   //`Cache the XPath expression and context.
   xpath.expr = "root/elem1";
   xpath.context = xmldoc;
   // Clone the XMLDOMSelection object.
   xpath2 = xpath.clone();
   temp1 = xpath.peekNode();  // temp1 == <elem1/>
   WScript.Echo("temp1: " + temp1.xml);
   temp2 = xpath2.peekNode();  // temp2 == <elem2/>
   WScript.Echo("temp2: " + temp2.xml);
   // Note that the position and context are maintained.


temp1: <elem1>Hello</elem1>
temp2: <elem1>Hello</elem1>

HRESULT clone(IXMLDOMSelection ** ppNode);


ppNode[out, retval]

The returned copy of the IXMLDOMSelection object.

Return Values


The value returned if the cloning is successful.


The value returned if the input argument is Null.

Implemented in: MSXML 3.0 and MSXML 6.0

© 2015 Microsoft