[Greasemonkey] DOMParser and element attributes

chris feldmann cfeldmann at gmail.com
Thu Jul 14 00:04:33 EDT 2005


OK I've got a DOMParser object parsing the XML I get back from google's 
spellcheck server (www.l.google.com <http://www.l.google.com> - 
64.233.161.99 <http://64.233.161.99> according to ethereal, fyi) and I want 
to get the attributes out. I thought maybe someone here could save me from 
what is so far a fruitless search. Anyway, I get this from google (sending '
*thisr anotther spelling sspeling*')
 
*<?xml version="1.0"?>**<spellresult error="0" clipped="0"
charschecked="32">**	<c o="0" l="5"
s="0">this	Thurs	theirs	those	theist</c>**	<c o="6" l="8"
s="1">another	anther	norther	Anthe	Anthea</c>**	<c o="24" l="8"
s="1">spelling	sapling	spieling	spilling	spoiling</c>**</spellresult>*

I want those ordinal and length values. I get the spellresults with this 
(response loaded into var xmlString):
 
		*var* parser = *new* DOMParser();
		*var* googleSez = parser.parseFromString(xmlString, 'application/xml');
		*var* replyBlox = googleSez.getElementsByTagName('c');

And then try various things such as this:
 
		*replyBlox.setAttribute('ordinal',
googleSez.getElementsByTagName('c').getAttribute('o'));*
		*replyBlox.setAttribute('letters',
googleSez.getElementsByTagName('c').getAttribute('l'));*

...which does not work, just as nothing else so far has. Can anyone tell me 
what will?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050713/eb631ed1/attachment-0001.htm


More information about the Greasemonkey mailing list