Microsoft XML SDK 2.6 - XML Reference

clone Method

Produces an exact copy of the current XMLDOMSelection object, with the same position and context.

Set NewObjXMLDOMSelection = objXMLDOMSelection.clone

JScript Example

//Create a DOMDocument2 object and load some XML:
xmldoc = new ActiveXObject("Msxml2.DOMDocument");
xmldoc.loadXML("<root><elem1>foo</elem1><elem2>bar</elem2></root>");
//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/>
temp2 = xpath2.peekNode();  // temp2 == <elem1/> Note the position and
// context are maintained.

See Also

Applies To: XMLDOMSelection Object