clone Method1

 

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

JScript Syntax

var NewObjXMLDOMSelection = objXMLDOMSelection.clone();  

Example

// Create a DOMDocument2 object and load some XML.  
xmldoc = new ActiveXObject("Msxml2.DOMDocument.6.0");  
xmldoc.loadXML("<root><elem1>Hello</elem1><elem2>World!</elem2></root>");  
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.  
}  

Output

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

C/C++ Syntax

HRESULT clone(IXMLDOMSelection ** ppNode);  

Parameters

ppNode[out, retval]
The returned copy of the IXMLDOMSelection object.

Return Values

S_OK
The value returned if the cloning is successful.

E_INVALIDARG
The value returned if the input argument is Null.

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

Applies to

IXMLDOMSelection