I'm not entirely happy with the XPath bits. If we had an nsXPathEvaluator member, or if the WebIDL API were on nsIDOMXPathEvaluator or something, all that stuff would need a lot less code...