f



How IE's and Firefox's XML DOM parsers deal with whitespace text nodes #2

Can someone please explain this section of this tutorial me?

http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp

The relevant text I do not understand is:

"Internet Explorer, when using node.childNodes[], will NOT contain
these white-space nodes. In Mozilla, those nodes will be in the
array."

and

"Internet Explorer will skip the white-space text nodes that are
generated between nodes (e.g. new line characters), while Mozilla will
not. So, in the example above, Mozilla browsers will alert 9 child
nodes, while Internet Explorer will alert 4."

I checked the said file: http://www.w3schools.com/dom/books.xml

In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements.

0
wtr_clr (75)
11/2/2007 2:28:32 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

1 Replies
706 Views

Similar Articles

[PageSpeed] 49

Water Cooler v2 wrote:

> The relevant text I do not understand is:
> 
> "Internet Explorer, when using node.childNodes[], will NOT contain
> these white-space nodes. In Mozilla, those nodes will be in the
> array."
> 
> and
> 
> "Internet Explorer will skip the white-space text nodes that are
> generated between nodes (e.g. new line characters), while Mozilla will
> not. So, in the example above, Mozilla browsers will alert 9 child
> nodes, while Internet Explorer will alert 4."
> 
> I checked the said file: http://www.w3schools.com/dom/books.xml
> 
> In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements.

The DOM object model knows different kind of nodes, it knows element 
nodes but it also knows text nodes. In the example document books.xml 
there is white space between the elements as the markup looks like this

<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>

and not like this

<bookstore><book category="COOKING"><title lang="en">Everyday 
Italian</title><author>Giada De 
Laurentiis</author><year>2005</year><price>30.00</price></book><book 
category="CHILDREN"><title lang="en">Harry Potter</title><author>J K. 
Rowling</author><year>2005</year><price>29.99</price></book>

The difference between the DOM implementations is whether such 
whitespace is modelled as text nodes or not.

With Mozilla it is, with IE respectively MSXML it depends on the setting 
of the property preserveWhiteSpace e.g. this example

var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.3.0');
xmlDocument.async = false;

xmlDocument.preserveWhiteSpace = true;

xmlDocument.load('http://www.w3schools.com/dom/books.xml');

alert(xmlDocument.documentElement.childNodes.length);

xmlDocument.preserveWhiteSpace = false;

xmlDocument.load('http://www.w3schools.com/dom/books.xml');

alert(xmlDocument.documentElement.childNodes.length);

alerts 9 first, then 4.

So with Mozilla and with IE/MSXML with preserveWhiteSpace set to true 
the object model contains white space text nodes between the book 
element nodes.

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
mahotrash (2052)
11/2/2007 3:38:47 PM
Reply:

Similar Artilces:

How IE's and Firefox's XML DOM parsers deal with whitespace text nodes
Can someone please explain this section of this tutorial me? http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp The relevant text I do not understand is: "Internet Explorer, when using node.childNodes[], will NOT contain these white-space nodes. In Mozilla, those nodes will be in the array." and "Internet Explorer will skip the white-space text nodes that are generated between nodes (e.g. new line characters), while Mozilla will not. So, in the example above, Mozilla browsers will alert 9 child nodes, while Internet Explorer will alert 4." I checked the said file: http://www.w3schools.com/dom/books.xml In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. ...

XML: How to remove whitespaces from element's text?
When I invoke getNodeValue() on the sub-element of the following XML document: <item> <sub> The text I'm interested in. </sub> </item> the returned text includes many pre- and trailing whitespaces. Is there a standard way to get rid of those whitespaces? I've tried: DocumentBuilderFactory.setIgnoringElementContentWhitespace(true); But that doesn't seem to work. Cheers, Berco Berco <donot@mail.me.com> scribbled the following: > When I invoke getNodeValue() on the sub-element of the following XML > document: > <item> > <sub> > The text I'm interested in. > </sub> > </item> > the returned text includes many pre- and trailing whitespaces. Is there a > standard way to get rid of those whitespaces? I've tried: > DocumentBuilderFactory.setIgnoringElementContentWhitespace(true); > But that doesn't seem to work. Just retrieve the node value as it is, and then call the trim() method on the resulting String. -- /-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "I am looking for myself. Have you seen me somewhere?" - Anon Wow! That is fast....and correct! Thanks a lot for that. Berco > Just retrieve the node value as it is, and then call the trim() > method on the resulting String. > > -- > /--...

Error? s = assignin('base','s',tf('s'));
Hi, I need a little help here. Could anyone please tell me what is wrong with this command? s = assignin('base','s',tf('s')); The matlab syntax is -- assignin(ws, 'var', val) Basically I just want to add s=tf('s') into the base workspace. Jack "Jack" <Jack@Jill.com> wrote in message news:ef3e449.-1@webcrossing.raydaftYaTP... > Hi, > I need a little help here. Could anyone please tell me what is wrong > with this command? > > s = assignin('base','s',tf('s')); > > The matlab syntax is -- assignin(ws, 'var', val) > Basically I just want to add s=tf('s') into the base workspace. What does the error message say? Something about too many output arguments, right? How many output arguments does the documentation for ASSIGNIN show that it should return? How many are you asking it to return? http://www.mathworks.com/access/helpdesk/help/techdoc/ref/assignin.html -- Steve Lord slord@mathworks.com ...

Graffiti 2
Under Graffiti 2, I have an impossible time getting capital k's, t's and i's using the 'traditional input' method. I have marginally greater success if I write on the screen. Ultimately, more often than not I end up having to resort to the keyboard entry mode. Are there any tips or tricks anyone can offer to assist? Harold Harold M. Goldner wrote: > Under Graffiti 2, I have an impossible time getting capital k's, t's and > i's using the 'traditional input' method. I have marginally greater > success if I write on the screen. ...

how to Update/insert an xml element's text----> (<element> text</element>)
hello friends, how can we update or insert into an xml Element. For example : ------------------- <?xml version="1.0"> <request> <main> <name>ISO8856</name> </main> </request> here when we run a java class file it should replace "ISO8856"with "ISO9001". Any Assistance or example. thanQ in adv. Ajay HANM wrote: > <?xml version="1.0"> > <request> > <main> > <name>ISO8856</name> > </main> > </request> > > here when we run a java class file it should replace "ISO8856"with > "ISO9001". Any Assistance or example. If you use the W3C DOM Level 3 Core as implemented in Java 1.5 and later then you can select the 'name' element and set its textContent e.g. Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.setTextContent("ISO09001"); If you use DOM Level 2 Core (as implemente in Java 1.4) then you need to access the firstChild and set its nodeValue Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.getFirstChild().setNodeValue("ISO09001"); -- Martin Honnen http://JavaScript.FAQTs.com/ Many good tutorials/articles exist on the web (and some bad ones, alas). I usually point people to http://www.ibm.com/xml -- Joe K...

XYpic's arrows and text's arrows in pdf
Hi. I'm sorry for my English. I use MiKTeX 2.5. I have this problem. Using XYpic, I'd like to have the same head for arrows in diagrams and arrows in text (\to, \mapsto, etc.). So I have used \SelectTips{cm}{} that should set computer modern for XYpic's arrows. If I compile in dvi (with latex), the heads are equal, but if I compile in pdf (with pdflatex, but also with latex+dvipdfm) the arrows in the text are smaller than XYpic's arrows (also prettier, I think). So: 1) why is there this difference between dvi and pdf? 2) how can I have equal arrows? Thank you very much, Luigi === Example === \documentclass{article} \usepackage[all]{xy} \SelectTips{cm}{} \begin{document} Compile with pdflatex. Arrows with small head: $\to$, $\mapsto$, etc. Arrows with big head: $\xymatrix@1{A \ar[r] & B}$ \end{document} === Luigi Balduzzi <MY_NAME.MY_SURNAME@iolREMOVE_THIS.it> wrote: > Hi. I'm sorry for my English. > I use MiKTeX 2.5. I have this problem. Using XYpic, I'd like to have > the same head for arrows in diagrams and arrows in text (\to, \mapsto, > etc.). So I have used \SelectTips{cm}{} that should set computer modern > for XYpic's arrows. If I compile in dvi (with latex), the heads are > equal, but if I compile in pdf (with pdflatex, but also with > latex+dvipdfm) the arrows in the text are smaller than XYpic's arrows > (also prettier, I think). So: > 1) why is there this difference between dvi and pdf...

100's of frames and 100's of alpha's into transparant GIF or PNG's
I render game sprites/floor tiles using lightwave. I output the frames and I output an alpha-image so I can seperate the objects from the renderings. I used to combine the alpha and the render in photoshop by hand, as photoshop can only load one batch of source files in it's action-macros. Now that the spritecount has risen into the double digits, I'm looking for a way to combine 100's of frames and 100's of alpha's into transparant GIF or PNG's. I have had no luck in photoshop for this, it only lets me specify one source folder per action. Does anyone have a clever ...

Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand
I'm still new here, and I just completed reading CLTL's documentation on packages and On Lisp's documentation on CLOS. It doesn't appear that Lisp has the equivalent of Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand. That is, there is no way I can do this (without new-function being defined): (new-function) and have it call some other function like this: (missing-symbol 'new-function) whose returning value will be evaluated as the value of new-function. Or did I miss something? Jonathan Gardner <...

The iPhone's features: What's new, what's not
http://crave.cnet.com/8301-1_105-9733965-1.html?tag=cnetfd.mt Unless you've cut yourself off from all media access this year, you know that on Friday, June 29 Apple will release its iPhone with AT&T. Ever since the device's unveiling last January, the tech world has been running in circles asking what the iPhone will be like, what it will do, and how it will do it. But because Apple hasn't been the leakiest of faucets when it comes to specs, the hype has resulted in a lot of speculation instead. Of course, that will all change in several days, as you can be sure everyone lucky...

Toronto: Now Accepting Resumes IT Professionals, CA's CGA's MBA's Financial Managers #2
Now Accepting Resumes ! We are getting ready for our busy season, and are now accepting resumes from active jobseekers. If you are an IT professional or Financial Manager we want to hear from you. We are planning a major marketing blitz to uncover those tough -to- find jobs out there, and you can be among the first to benefit. Both contractors and perm fulltime jobseekers are welcome. If you have previously sent a resume, you are invited to send us a new, up to date one to keep your information current. Resumes to jpapish (at) spectrumjobs.com We abide by PIPEDA and...

Nvidia's 'Nalu' vs ATI's 'Ruby'
http://karpo.org/images/Dunno/Ruby.jpg Nvidia's GeForce 6800 (NV40) 'Nalu' demo consists of 300,000 polygons. very very impressive shit! ATI's Radeon X800 (R420) 'Ruby' demo consists of only 80,000 polygons. however it is also rendering a background with other elements. closer to what would be in an actual game. now, console gamers: keep in mind, whatever ATI has been able to come up with at this point (re: the R420 / Radeon X800) is a stepping stone to what they'll be able to have in 2005 for Xbox Next, and in 2006 for GCNext :) On 14 Apr 2004 21:33:15 -0700, nvidianv55@mail.com (NV55) wrote: >http://karpo.org/images/Dunno/Ruby.jpg > >Nvidia's GeForce 6800 (NV40) 'Nalu' demo consists of 300,000 polygons. >very very impressive shit! > >ATI's Radeon X800 (R420) 'Ruby' demo consists of only 80,000 polygons. >however it is also rendering a background with other elements. closer >to what would be in an actual game. > >now, console gamers: keep in mind, whatever ATI has been able to come >up with at this point (re: the R420 / Radeon X800) is a stepping stone >to what they'll be able to have in 2005 for Xbox Next, and in 2006 for >GCNext :) Wow............. I am impressed !! Must ask for an advanced payment of my Social Security to buy these consoles. Both should sink like rocks if not 100%backward compatible with existing non-Next software. Also, a huge marketing problem for n...

Updating to 3.2 on SuSE -- what's the deal w/Suse's KDEBASE?
[posted to both ...suse and ...kde since there is an intersection of interest here] I see that "the latest" kde is out, and from other posts I hear SuSE 9.1 isn't due for another couple of weeks -HOWEVER- SuSE is nice enough to have an easily-installable version for prior SuSE releases... /almost!/ The brain-dead easy part about this is that you can add an "alternate" source for software, point it to the SuSE FTP server and down some long chain of directories ending in ".../yast-source", and tell Yast to "update" whatever it sees. The brain-dead p...

cell's offsetHeight not equal to cell's height?? firefox & IE
Tested in IE7 and FF2. I have 2 frames, 2 similar tables in them, similar CSS. (I have 1px cellpadding, and 1px border aroud the cells. From one frame I read the offsetHeight of a cell (getElementById), and set the height of the corresponding cell in the other frame. Here: window.parent.frames["lft"].document.getElementById('r2').style.height=(document.getElementById('r2'i).offsetHeight) + 'px'; Everything works perfectly, cell gets resized, BUT then I read back the height of both cells, here: alert(document.getElementById('r2').offsetHeight + '...

[News] Microsoft's 'Open' XML Ridiculed
Microsoft's draft Open XML straitjacket arrives ,----[ Quote ] | While Microsoft is proposing this as the better alternative to ODF | (OpenDocument Format), as Andrew "Andy" Updegrove, a partner with Boston | law firm Gesmer Updegrove LLP and the editor of ConsortiumInfo.org, | points out, the level is so high, that if Open XML became a standard, | "only clones can be built, which is good for interoperability, but death | to innovation. It can also be death to competition, since if (as in this | case) the standard is based on an existing product, then no would-be | competit...

JSP, Servlet's, EJB's, Bean's?
I am currently developing an application where I call command line programs and capture the output. This is fine. What I am doing is creating a web interface for these programs using JSP/Servlets. What I would like to do is be able to call these programs. Using buttons or something, and dumping the output into a text area. I have a servlet that I generates the output that I need. My question is How do I get that output into the textarea? When I call a new function I want to be able to append the text to the end of the text area. I was told in another group that I would need a...

*.xml files - carriage return's go into file in VMS
Can anyone help me with how to search/repl or convert the file to eliminate the carriage returns in the xml file in VMS? Thanks, Chuck $ dir/full abw_from_msword.xml Directory USER$DISK:[PXZA003] ABW_FROM_MSWORD.XML;1 File ID: (80080,16,0) Size: 34/36 Owner: [EXCERPT,PXZA003] Created: 27-MAR-2009 09:56:57.02 Revised: 27-MAR-2009 09:56:57.49 (1) Expires: <None specified> Backup: <No backup recorded> Effective: <None specified> Recording: <None specified> Accessed: <None specified> Attributes: <None s...

[News] Microsoft's XML Patents Pose Problems to USPTO's Declining Status
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Patents and Tacit Knowledge ,----[ Quote ] | I think the source of the problem in the patent system may be linked to a | point Friedrich Hayek made long ago about our tendency to overrate the | economic importance of theoretical knowledge and vastly underestimate the | importance of tacit or practical knowledge. The non-obviousness requirement, | tied to the standard of an observer skilled in the appropriate art, is | supposed to make the patent system sensitive to this kind of knowledge. But | if examiners have to defend their judgments of...

How do I embed a link into the text of an xml element's value?
Hi, Thanks in advance for any help in this matter. I need to embed a link in the text portion of an xml element's value. For example, <some_element> Hi, my name is Tom, and you can find my webpage <URL link="www.xyz.net/~tom">here</URL> </some_element> so when this element is transformed into xhtml (using xsl, of course) we will see the link properly. If anyone can offer me a suggestion regarding how to tackle this issue, I would much appreciate it. Tom If you include the protocol in your link attribute (eg, http://www.xyz.net/~tom) then you can ...

Simple way to loop a directory's files and put the file's text into string variable
Can someone please give me some code sample on how to do this in VB? So far I tried two methods and I've read of a third one that uses "DIR" but I don't know how to write the "DIR" method. I need to know which code would loop through the files fastest? Or they are all the same? I have SQL files that I want to read one by one and using SQL DMO execute them. Here's one sample I have for looping files... Dim sSQL As String Dim iFile As Integer FileListBoxTest.Path = "C:\Temp" FileListBoxTest.Pattern = "*aa.sql" For i = 0 To FileListBoxTest...

Linux's console text mode make video card's fan spin up and use more power?
Hello! I noticed most of the times my old NVIDIA GeForce 8800 GT video card's fan is quiet in KDE v3.5.10 with Compiz. When I exit out of X (used startx to start X.org) to text mode console, my fan will spin up louder and according to my old APC UPS, more power is used: Before "startx" command: APC : 001,037,0905 DATE : 2011-06-22 20:19:49 -0700 HOSTNAME : MyBox VERSION : 3.14.8 (16 January 2010) debian UPSNAME : MyBox CABLE : USB Cable MODEL : Back-UPS RS 1500 UPSMODE : Stand Alone STARTTIME: 2011-06-14 20:44:35 -0700 STATUS : ONLINE LINEV : 115.0 Volts LOADPCT : 20.0 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 44.5 Minutes MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds SENSE : High LOTRANS : 097.0 Volts HITRANS : 138.0 Volts ALARMDEL : Always BATTV : 26.8 Volts LASTXFER : Low line voltage NUMXFERS : 0 TONBATT : 0 seconds CUMONBATT: 0 seconds XOFFBATT : N/A SELFTEST : NO STATFLAG : 0x07000008 Status Flag MANDATE : 2005-03-16 SERIALNO : QB0[deleted] BATTDATE : 2005-03-16 NOMINV : 120 Volts NOMBATTV : 24.0 Volts NOMPOWER : 865 Watts FIRMWARE : 8.g8 .D USB FW:g8 APCMODEL : Back-UPS RS 1500 END APC : 2011-06-22 20:20:22 -0700 After startx command is run and KDE v3.5.10 desktop with Compiz is up and idling: APC : 001,037,0905 DATE : 2011-06-22 20:20:49 -0700 HOSTNAME : MyBox VERSION : 3.14.8 (16 January 2010) debian UPSNAME : MyBox CABLE : USB Cable MODEL : Back-UPS RS 1500...

Look! Up in the sky! It's a bird! It's a plane! No-- it's WONDER
Yes, Wonder Chimpie-- strange primate from another planet!! Knows everything about IT (with the exception of a proxy server and how to kill file). All bow down when he comes around! Thank you, Wonder Chimpie, for saving us from ourselves! ~~~~~~~~~~~~~~~~~~~~~ This message was posted via one or more anonymous remailing services. The original sender is unknown. Any address shown in the From header is unverified. ...

EA treats it's employee's worse than it's customers!
Just more reasons not to by Anything from EA http://www.livejournal.com/users/ea_spouse/ http://www.igda.org/qol/open_letter.php On Sun, 21 Nov 2004 14:30:51 GMT, "Bill" <mrspamnobillo@nospam.bom> wrote: >Just more reasons not to by Anything from EA > >http://www.livejournal.com/users/ea_spouse/ > >http://www.igda.org/qol/open_letter.php I would love to start boycotting EA because of their poor treatment of staff, but I am already boycotting them for making so many crap games they are actually damaging the industry and our art. "Bill" <mrsp...

How do you cool this thing? It's all the user's fault!!! He's a moron!!!
Well, looks like the adepts are trying to convince the masses burning hot macbook pros are the norm http://www.amazon.com/review/R1B7U99O7KWW0I/ref=cm_cr_rev_detup_redir?_encoding=UTF8&cdPage=1&asin=B003GSLU3E&newContentNum=13&store=pc&newContentID=Mx3FQEIJIGB90CN#Mx4BCYXL68C6DD hp apparently is not alone with its freaking hot envy 17 In article <111e260e-af04-435c-b61b-f4dda7c5fdad@8g2000prt.googlegroups.com>, AD <isquat@gmail.com> wrote: > Well, looks like the adepts are trying to convince the masses burning > hot > macbook pros are the norm > > http://www.amazon.com/review/R1B7U99O7KWW0I/ref=cm_cr_rev_detup_redir?_encodin > g=UTF8&cdPage=1&asin=B003GSLU3E&newContentNum=13&store=pc&newContentID=Mx3FQEI > JIGB90CN#Mx4BCYXL68C6DD > > hp apparently is not alone with its freaking hot envy 17 What do you think can be done? There is an inherent relationship between computing power and heat. Advances in technology may change the formula, but the relationship will remain. -- "The iPhone doesn't have a speaker phone" -- "I checked very carefully" -- "I checked Apple's web pages" -- Edwin on the iPhone "It is Mac OS X, not BSD.' -- 'From Mac OS to BSD Unix." -- "It's BSD Unix with Apple's APIs and GUI on top of it' -- 'nothing but BSD Unix' (Edwin on Mac OS X) '[The IBM PC]...

It's a Bird, it's a plane, no! umm, it's Super Boid?
Hey Guys, I have something actually working that seems allot like Swarm Technology to me. The system features many smaller parts that seem allot like "Boids" (or "Agents"). I'd be tempted to call them "Dorts" because they get thrown straight at the target and fire on my machine at about 2,000 per second (in 1.9). Not very "natural" - one would not want to have mosquitoes able to do that :) There's no "in-flight" communication between the Boids - their life cycle involves trying to attain values for a list of required attributes and a docking with a "HelperClass" (see Ruleby also) for any in-depth calculations. They make their assertions, record all the results, and wait to be debriefed after they have landed. So are these things Boids or not? For example: They are fired sequentially so they are not buzzing around sending signals to each other. However, if a Boid is assigned a lower pass number it can "leave information" for a Boids fired on later passes - so there is inter_boidal_communications :) - but only after their "flight" / period of activity. It's taken me almost 3 years to get this all this far along Right now, however, I can go on localhost and author 10 new real almost guaranteed to work "Boids" easily in an hour.(When I started and did these by hand they could take a full day.) Mostly all I have to do now is make multiple choices. (Lots of Ruby ...

Web resources about - How IE's and Firefox's XML DOM parsers deal with whitespace text nodes #2 - comp.text.xml

Resources last updated: 3/13/2016 9:53:11 PM