How to count LI elements from a list

Firefox, Safari and Opera supports document.evaluate which makes life easier since you can use XPath to get the nodes you want:

var ul = document.getElementById("myul");
var result = document.evaluate("li", ul, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);

var nextLi;

while (nextLi = result.iterateNext()) {
	alert(nextLi.firstChild.data);
}

More elegant and powerful solution than above, but it does not work in IE…

:nono: