Skip to content Skip to sidebar Skip to footer

JavaScript: Iterating Over Document.evaluate() XPathResult Returns Null

I am trying to get all objects but it doesn't work. var tmp = document.evaluate('//tr', document, null, XPathResult.ANY_TYPE, null); tmp.iterateNext returns me null;

Solution 1:

If you are working in IE, then you should know that document.evaluate does not exist there (see this similar question and the last couple of paragraphs here).

Why not just document.getElementsByTagName("tr");?


Solution 2:

In my opinion, using an existing JS libraries such as JQuery is usually more reliable in cases like this.


Solution 3:

document.getElementsByTagName("tr"); 

It also will not work, because IE some versions doesn't support this method for elements, which has not such attribute like 'name'.


Post a Comment for "JavaScript: Iterating Over Document.evaluate() XPathResult Returns Null"