[Greasemonkey] XPath problem

Gareth Andrew freega at freegarethandrew.org
Sun Dec 18 01:02:07 EST 2005


Just off the top of my head... 
Have you tried XPathResult.UNORDERED_NODE_ITERATOR_TYPE.  I think if you
want to use snapshots you are meant to use
xpathResult.snapshotItem(index) to access the results.  It might also be
worth looking at the values of xpathResult.resultType and
xpathResult.snapshotLength.
http://www.xulplanet.com/references/objref/XPathResult.html is a handy
resource.

Hope this helps,

Gareth

On Sun, 2005-12-18 at 01:19 +0100, Guillaume Mouron wrote:
> Hi !
> 
> I am trying to use a XPath expression and modify the
> results like this :
> 
> var xpathResult =
> document.evaluate("//a[contains(@href,'javascript:openRadio')]",
> document, null, XPathResult.UNORDERED_SNAPSHOT_TYPE,
> null);
>       var thisLink = xpathResult.iterateNext();
>       while (thisLink) {
>         var link = thisLink.getAttribute("href");
>         link.match(/javascript:openRadio\('(.*)'\)/);
>           thisLink.setAttribute("href",RegExp.$1);
>         thisLink = xpathResult.iterateNext();
>       }
> 
> But I get an error :
> [Exception... "An attempt was made to use an object
> that is not, or is no longer, usable"  code: "11"
> nsresult: "0x8053000b
> (NS_ERROR_DOM_INVALID_STATE_ERR)"  location:
> "<unknown>"]
> 
> I first put XPathResult.ANY_TYPE but I had the error,
> as I read here :
> http://www.archivesat.com/greasemonkey.mozdev.org/thread3625.htm
> I've put XPathResult.UNORDERED_SNAPSHOT_TYPE but the
> error remains ...
> So what's wrong ? :(
> 
> 
> 	
> 
> 	
> 		
> ___________________________________________________________________________ 
> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
> Téléchargez sur http://fr.messenger.yahoo.com
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey



More information about the Greasemonkey mailing list