[Greasemonkey] DOMParser and element attributes

John gm at plsek.id.au
Thu Jul 14 14:22:44 EDT 2005


chris feldmann wrote:

>
>		/replyBlox.setAttribute('ordinal', googleSez.getElementsByTagName('c').getAttribute('o'));/
>		/replyBlox.setAttribute('letters', googleSez.getElementsByTagName('c').getAttribute('l'));/
>
Haven't really looked into what you are trying to achieve, however, 
getElementsByTagName in your example returns an array of all 'c' elements

so, you'd need to do something like

        var replyBlox = googleSez.getElementsByTagName('c');
        for(i=0; i< replyBlox.length; i++)
          {
             replyBlox[i].setAttribute('ordinal', 
replyBlox[i].getAttribute('o'));
             replyBlox[i].setAttribute('letters', 
replyBlox[i].getAttribute('l'));
          }

John


More information about the Greasemonkey mailing list