| Newsgroups |
gmane.comp.mozilla.devel.xml |
| Organization |
http://groups.google.com |
| Message-ID |
<[email protected]> |
Hello.
I'm trying to develop a little GreaseMonkey script, on the http://forum.hardware.fr
page.
I'd like to get all the links inside all the subsections of the page:
http://www.hardware.fr
The subsections are named 'cat1', 'cat2', etc, up to 'cat16'.
When I do:
var allLinks, thisLink;
allLinks = document.evaluate('//a[@href]',
document.getElementById('cat16'), null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++)
{
thisLink = allLinks.snapshotItem(i);
GM_log(thisLink);
}
It returns all the links of the page, not the links of the 'cat16'
element. Why ?
Ie, it has the same results than
allLinks = document.evaluate('//a[@href]', document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
According to this page:
http://diveintogreasemonkey.org/patterns/match-attribute.html
it shouldn't:
Quote:
"The second parameter can be any element, and the XPath query will
only return nodes that are children of that element. So if you already
have a reference to an element (say, from document.getElementById or a
member of a document.getElementsByTagName array), you can restrict the
query to search only children of that element."
Thanks a lot.