Hi all,
I got a problem with childNodes.leng th, I use the following XML for my
guestbook:
<?xml version="1.0" encoding="ISO-8859-1"?>
<guestbook>
<entry>
<from>Q1tum</from>
<mail>kuukeleku u at gmail dot com</mail>
<date>2006-05-16 09:41</date>
<message>Firs t test message</message>
</entry>
<entry>
<from>Q1tum</from>
<mail>kuukeleku u at gmail dot com</mail>
<date>2006-05-17 09:41</date>
<message>Second e test message</message>
</entry>
</guestbook>
when I use the following script to check I get different output in IE
and FireFox:
var xml = response.respon seXML;
var table = document.getEle mentById('guest book');
var num = xml.getElements ByTagName('gues tbook')[0].childNodes.len gth;
alert(num);
IE alerts 2
FF alerts 5
Anyone have a idea why that is?
Regards,
Q1tum 12 4490
Q1tum wrote: Hi all,
I got a problem with childNodes.leng th, I use the following XML for my guestbook:
<?xml version="1.0" encoding="ISO-8859-1"?> <guestbook> <entry> <from>Q1tum</from> <mail>kuukeleku u at gmail dot com</mail> <date>2006-05-16 09:41</date> <message>Firs t test message</message> </entry> <entry> <from>Q1tum</from> <mail>kuukeleku u at gmail dot com</mail> <date>2006-05-17 09:41</date> <message>Second e test message</message> </entry> </guestbook>
when I use the following script to check I get different output in IE and FireFox:
var xml = response.respon seXML; var table = document.getEle mentById('guest book');
var num = xml.getElements ByTagName('gues tbook')[0].childNodes.len gth;
alert(num);
IE alerts 2 FF alerts 5
Anyone have a idea why that is?
The whitespace between tags?
FF is seeing <textnode><entr y><textnode><en try><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.
Ian Collins wrote: FF is correct, the whitespace should included. Probably IE applies HTML rather than XML rules when parsing your XML and strips the extraneous whitespace.
FF is wrong, no one of XML/HTML specs requires to reflect source code
pretty-print in the DOM tree. Even W3C did not reach yet such level of
idioticy. That was an original wrong reading of very badly written W3C
specs, and now it will be a painful process of admitting and correcting
it I'm affraid.
See <https://bugzilla.mozill a.org/show_bug.cgi?id =26179> for the
general discussion about the phantom nodes bug.
For the time being OP can use one of numerous tree walkers learned to
skip on phantom nodes; or use the special phantom nodes bug adjusted
pretty-print like:
<foobar<foo <bar </bar </foo </foobar>
VK wrote: See <https://bugzilla.mozill a.org/show_bug.cgi?id =26179> for the general discussion about the phantom nodes bug.
You also can read/add some to the blog at
<http://laughingmeme.or g/articles/2005/11/11/bug-26179-mozilla-reports-existence-of-phantom-text-nodes-in-the-dom>
That is a real war "Web developers vs. Firefox developers" going for
more than one year already. So instead of add some nasties about the
phantom nodes, you can join to the opposite camp (if you like to be
sadomasohistic :-) or if you indeed manage to find some reason in their
reasonnings).
VK wrote: Ian Collins wrote:
FF is correct, the whitespace should included. Probably IE applies HTML rather than XML rules when parsing your XML and strips the extraneous whitespace.
FF is wrong, no one of XML/HTML specs requires to reflect source code pretty-print in the DOM tree. Even W3C did not reach yet such level of idioticy. That was an original wrong reading of very badly written W3C specs, and now it will be a painful process of admitting and correcting it I'm affraid.
See <https://bugzilla.mozill a.org/show_bug.cgi?id =26179> for the general discussion about the phantom nodes bug.
Interesting, my interpretation of the specs was that the extraneous
whitespace should be included unless the document's schema or DTD
excluded PCDATA as a child element.
--
Ian Collins.
On 17/05/2006 12:16, VK wrote: Ian Collins wrote:
FF is correct, the whitespace should included. Probably IE applies HTML rather than XML rules when parsing your XML and strips the extraneous whitespace. FF is wrong,
It just never seems to occur to you that you are, more often than not.
no one of XML/HTML specs [...]
With regard to white space, XML and SGML differ.
In section 2.10, of the XML specification, it states quite clearly:
An XML processor must always pass all characters in a document
that are not markup through to the application. A validating
XML processor must also inform the application which of these
characters constitute white space appearing in element content.
As Firefox doesn't typically use a validating XML processor, white space
in element content will be treated simply as character data, and the DOM
Core Level 2 specification states in the introductory section, "What the
Document Object Model is":
Note: There may be some variations depending on the parser
being used to build the DOM. For instance, the DOM may not
contain whitespaces in element content if the parser discards
them.
So, conversely, if the parser does pass on white space characters (and
we've established that it may), the document tree may contain the text
nodes that Fx includes.
With applications of SGML, the situation is different as there are rules
for collapsing white space and ignoring line terminators after start
tags and before end tags. White space in element content may also need
to be ignored, but as I don't have a copy of the SGML specification, I
couldn't say for certain.
In any case, even if it is 'fixed' in future browser versions, one still
needs cope with past and current implementations , therefore whining
about it is pointless.
[snip]
For the time being OP can use one of numerous tree walkers learned to skip on phantom nodes;
Or write one. It's trivial.
or use the special phantom nodes bug adjusted pretty-print like:
<foobar ><foo ><bar ></bar ></foo </foobar>
If you want to do something that stupid, that's your choice, but don't
recommend it to anyone else. I'm sure the OP is capable of writing a
loop in order to obtain a particular child or sibling element.
Mike
--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Michael Winter wrote: On 17/05/2006 12:16, VK wrote:
Ian Collins wrote:
FF is correct, the whitespace should included. Probably IE applies HTML rather than XML rules when parsing your XML and strips the extraneous whitespace.
FF is wrong,
It just never seems to occur to you that you are, more often than not.
no one of XML/HTML specs [...]
With regard to white space, XML and SGML differ.
In section 2.10, of the XML specification, it states quite clearly:
An XML processor must always pass all characters in a document that are not markup through to the application. A validating XML processor must also inform the application which of these characters constitute white space appearing in element content.
Thanks for the reference, I was sure I'd read this somewhere.
As Firefox doesn't typically use a validating XML processor, white space in element content will be treated simply as character data, and the DOM Core Level 2 specification states in the introductory section, "What the Document Object Model is":
Note: There may be some variations depending on the parser being used to build the DOM. For instance, the DOM may not contain whitespaces in element content if the parser discards them.
So, conversely, if the parser does pass on white space characters (and we've established that it may), the document tree may contain the text nodes that Fx includes.
With applications of SGML, the situation is different as there are rules for collapsing white space and ignoring line terminators after start tags and before end tags. White space in element content may also need to be ignored, but as I don't have a copy of the SGML specification, I couldn't say for certain.
I think that's the cause of the difference, IE parses XML as HTML thus
collapses the whitespace.
--
Ian Collins.
Ian Collins wrote: Michael Winter wrote:
[...] As Firefox doesn't typically use a validating XML processor, white space in element content will be treated simply as character data, and the DOM Core Level 2 specification states in the introductory section, "What the Document Object Model is":
Note: There may be some variations depending on the parser being used to build the DOM. For instance, the DOM may not contain whitespaces in element content if the parser discards them.
So, conversely, if the parser does pass on white space characters (and we've established that it may), the document tree may contain the text nodes that Fx includes.
With applications of SGML, the situation is different as there are rules for collapsing white space and ignoring line terminators after start tags and before end tags. White space in element content may also need to be ignored, but as I don't have a copy of the SGML specification, I couldn't say for certain. I think that's the cause of the difference, IE parses XML as HTML thus collapses the whitespace.
Is that an excuse? I thought the HTML specification dealt with white
space from the perspective of presentation, not a DOM.
For example, some written languages require that all white space is
removed and others do not so it would be silly to remove it from the DOM
depending on the language used.
I thought that whitespace should be preserved because if CSS is to be
used to display content, you can't remove whitespace (other than
collapsing it) that might be required by CSS, so better to preserve it
and let CSS do its thing.
There is a concept of treating white space in block and inline elements
differently, but CSS block elements can become inline and vice versa, so
again at the DOM level it would be silly to remove whitespace based on a
node being a block element when it might be later changed to inline (or
some other display attribute value).
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/faq/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: adam |
last post by:
i'm working on a portion of a CMS that allows content-admins to browse
a product list, and add individual products into the taxonomy by
clicking checkboxes next to categories they might belong in.
since the taxonomy is a rather long list, i'm hiding and showing divs
for the secondary and tertiary links, so when a user clicks on the
checkbox for the parent category, the children appear in a second (and
third) div, with checkboxes of their...
|
by: Ron Brennan |
last post by:
Good evening.
<span id=fileList>
<input type=hidden name=file id=file_0 value=Name/>
</span>
....
document.getElementById(fileList).childNodes
The childNodes is giving me two children: 1) file_0 and 2) undefined.
|
by: chuck |
last post by:
Hi,
I am modifying some code from here
http://www.quirksmode.org/dom/domform.html
I have a div 'readroot' that I clone. I change the change the id and
name of the childnodes of 'readroot' to the original name plus a
number(counter).
The problem is I have i have a div 'serials' inside 'readroot' and the
childnodes of
|
by: Q1tum |
last post by:
Hi all,
I have a problem with getting the amount of childs in a XML structure,
the strucure is somewhat like the following:
<?xml version="1.0" encoding="iso-8859-1"?>
<cms>
<num>21</num>
<xmlnames>
<field>id</field>
|
by: Jake Barnes |
last post by:
This weekend I decided to play around with Javascript a little and try
to teach myself some things about AJAX and DOM. I've been doing
experiments on this page:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
If you go there and click in any box, you'll get some controls. If you
then click "Add an Image" you'll have the chance to add an image. But
how many child elements are there in the box that communicates with
you? I count...
| |
by: yawnmoth |
last post by:
Given an element ID, is there a way to figure out what index one would
need to use in the parentNode's childNodes array to get at that
element?
For example...
<body>
<div id="parent">
<div id="a">a</div>
<div id="b">b</div>
|
by: Moses |
last post by:
HI
The Value for childNodes.length differs with mozilla and IE
Is it problem with my coding..... I could not under
stood.............
The following is the details
|
by: windandwaves |
last post by:
Hi Folk
I want to add an "onClick" function to the radio boxes, but I am
having trouble. Can you help me
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
|
by: willyWEB66 |
last post by:
Hi everyone,
I have this code in javascript where the XML file is loaded and displayed to an html using XSLT. It works fine in IE but not in Firefox. My problem is in the looping to the childNodes. It seems that Firefox does not recognize this line of code >> xmlDoc.getElementsByTagName("urlValue").childNodes.nodeValue
I'm not sure if this is the line that is not working, or the lines before it. I'm looping to the childNodes to compare to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |