Re:NodeList returned includes "\n" as nodes
- -----BEGIN PGP SIGNED MESSAGE-----
From the W3Schools website, http://www.w3schools.com/Dom/prop_element_childnodes.asp
"Firefox, and most other browsers, will treat empty white-spaces or
new lines as text nodes, Internet Explorer will not. So, in the
example above, the output will be different."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Ask me how you can start digitally signing your email!
-----END PGP SIGNATURE-----
- On Sat, 2008-08-30 at 13:07 -0400, Timothy Stone wrote:
> When I query the document for various childNodes, I'm getting theNot really. The Standard says that any whitespace between nodes is a
> NodeList, plus "\n" as nodes, doubling the returned childNodes of a
> particular element.
> The XHR is running on Firefox 3/Mac. It might be an implementation
> Any tips on this? Pointers already posted? My search of the list was
> not as effective as I might have liked it. Right now I'm just looping
> through the NodeList and testing its nodeType against "3" and
> it. Any better way?
own Text Node, and Firefox implements it this way. It's annoying, but
it is the standard, and you do have to develop against it. Because of
the way the standard is developed, it does seem like you're expected to
do a lot more of "getElementsByTagName" instead of iterating over
childNodes, but if iterating childNodes is what makes sense in your
problem space, what you're doing is reasonable.