Compability: Internet Explorer
This method resets the iterator for the collection.
The reset method resets the iterator to the point before the first item in the collection, so the next call to the nextNode method will return the first node.
XML:
<currencies>
<currency>CHF Swiss Francs</currency>
<currency>DEM German Deutsche
Marks</currency>
<currency>GBP United Kingdom
Pounds</currency>
<currency>JPY Japanese Yen</currency>
<currency>USD United States
Dollars</currency>
</currencies>
JavaScript:
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("currencies.xml");
node_list = xml_doc.getElementsByTagName("currency");
n = node_list.length
curr_node = node_list.item(n-1);
document.write(curr_node.xml);
node_list.reset();
curr_node = node_list.nextNode();
document.write("<br>" + curr_node.xml);
USD United States Dollars
CHF Swiss Francs
In this example, we load the 'currencies.xml' file and create a collection of all 'currency' nodes. The code then determines how many items are in the collection using the length property, and displays the text of the last node. The code then calls the reset method to reposition the iterator, and the nextNode method to return the first node in the list. The text of that node is also displayed.