childNodes.length IE和FF的区别 [英] childNodes.length IE and FF difference
问题描述
大家好,
我遇到了childNodes.length的问题,我使用以下XML作为我的
留言簿:
<?xml version =" 1.0" encoding =" ISO-8859-1"?>
< guestbook>
< entry>
< from> Q1tum< ; / from>
< mail> kuukelekuu at gmail dot com< / mail>
< date> 2006-05-16 09:41< / date>
< message>第一条测试信息< / message>
< / entry>
< entry>
< from> Q1tum< / from>
< mail> kuukelekuu at gmail dot com< / mail>
< date> 2006-05-17 09: 41< / date>
< message> Seconde测试消息< / message>
< / entry>
< / guestbook>
当我使用以下脚本检查我在IE中获得不同的输出
和FireFox:
var xml = response.responseXML;
var table = document.getElementById(''guestbook'');
var num = xml.getElementsByTagName(''guestbook '')[0] .childNodes.length;
alert(num);
IE提醒2
FF提示5
任何人都知道为什么会这样?
问候,
Q1tum
Q1tum写道:大家好,
我遇到了childNodes.length的问题,我使用以下XML作为我的
留言簿:
<?xml version =" 1.0" encoding =" ISO-8859-1"?>
< guestbook>
< entry>
< from> Q1tum< / from>
< mail> kuukelekuu at gmail dot com< / mail>
< date> 2006-05-16 09:41< / date>
< message>首先测试消息< / message>
< / entry>
< entry>
< from> Q1tum< / from>
< mail> kuukelekuu at gmail dot com< / mail>
< date> 2006 -05-17 09:41< / date>
< message> Seconde测试消息< / message>
< / entry>
< / guestbook>
当我使用以下脚本检查我在IE中获得不同的输出
和FireFox:
var xml = response.responseXML;
var table = document.getElementById(' 'guestbook'');
var num = xml.getElementsByTagName(''guestbook'')[0] .childNodes.length;
alert(num);
FF警报5
任何人都知道为什么会这样?
标签之间的空格?
FF正在看< textnode>< entry>< textnode>< entry>< textnode>
检查子节点类型。
-
Ian Collins。
嗯,我检查过之前我在论坛上发现了这个问题,
然后它显示了我同样的结果.....
我刚试了一遍,现在它正常工作:s
奇怪但是谢谢,当我输入没有换行符的XML时,它可以工作:)
Q1tum写道:嗯,我检查过之前因为我在论坛上发现了这个问题,
然后就显示了我得到了相同的结果.....
我只是再次尝试它,现在它正常工作:s
奇怪但是谢谢,当我输入XML时它会起作用没有换行符:))
FF是正确的,应包括空格。解析你的XML时可能IE应用HTML
而不是XML规则并删除无关的
空格。
-
Ian Collins。
Hi all,
I got a problem with childNodes.length, I use the following XML for my
guestbook:
<?xml version="1.0" encoding="ISO-8859-1"?>
<guestbook>
<entry>
<from>Q1tum</from>
<mail>kuukelekuu at gmail dot com</mail>
<date>2006-05-16 09:41</date>
<message>First test message</message>
</entry>
<entry>
<from>Q1tum</from>
<mail>kuukelekuu at gmail dot com</mail>
<date>2006-05-17 09:41</date>
<message>Seconde test message</message>
</entry>
</guestbook>
when I use the following script to check I get different output in IE
and FireFox:
var xml = response.responseXML;
var table = document.getElementById(''guestbook'');
var num = xml.getElementsByTagName(''guestbook'')[0].childNodes.length;
alert(num);
IE alerts 2
FF alerts 5
Anyone have a idea why that is?
Regards,
Q1tum
解决方案Q1tum wrote:Hi all,
I got a problem with childNodes.length, I use the following XML for my
guestbook:
<?xml version="1.0" encoding="ISO-8859-1"?>
<guestbook>
<entry>
<from>Q1tum</from>
<mail>kuukelekuu at gmail dot com</mail>
<date>2006-05-16 09:41</date>
<message>First test message</message>
</entry>
<entry>
<from>Q1tum</from>
<mail>kuukelekuu at gmail dot com</mail>
<date>2006-05-17 09:41</date>
<message>Seconde test message</message>
</entry>
</guestbook>
when I use the following script to check I get different output in IE
and FireFox:
var xml = response.responseXML;
var table = document.getElementById(''guestbook'');
var num = xml.getElementsByTagName(''guestbook'')[0].childNodes.length;
alert(num);
IE alerts 2
FF alerts 5
Anyone have a idea why that is?
The whitespace between tags?
FF is seeing <textnode><entry><textnode><entry><textnode>
Check the child node types.
--
Ian Collins.
Hmm, I checked that before becouse I found that issue on the forums,
then it was showing me the same result.....
I just tried it again and now it is working correctly :s
Strange but thanks, it works when I enter the XML with no linebreaks :)
Q1tum wrote:Hmm, I checked that before becouse I found that issue on the forums,
then it was showing me the same result.....
I just tried it again and now it is working correctly :s
Strange but thanks, it works when I enter the XML with no linebreaks :)
FF is correct, the whitespace should included. Probably IE applies HTML
rather than XML rules when parsing your XML and strips the extraneous
whitespace.
--
Ian Collins.
这篇关于childNodes.length IE和FF的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!