IXMLDOMSelection::Clone - Why would one use this function?
Posted on 2001-08-20
When I tried to this function after a selectNodes call, it did not clone the nodes in the list. I would have to call cloneNode to actually clone the node itself. Therefore, I was wondering, what would someone use this function for?
Here is a Microsoft example of the Clone function:
//Create a DOMDocument2 object and load some XML:
xmldoc = new ActiveXObject("Msxml2.DOMDocument");
//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.