RE: [xmljs-users] ELEMENT_NODE Vs TEXT_NODE
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2005-04-15 14:57:01
|
<< so while "preserveWhiteSpace=false" will handle "[ fred ]", the extra tabs are all converted to their own type3 node, yes? >> Yup, that's probably the deal. I might even call that a bug, but I'd have to see how other parsers handle that before addmitting a mea culpa :) David --- Barry Beattie <Ba...@al...> wrote: > > thanx for your help, David. > > >> It should be off by default though > > aye, it is and explicitly setting it to "false" didn't quite fix it. > > but you *were* on the right track David, there *was* whitespace _between_ the nodes themselves - > usually TAB's. > > <f_name> <![CDATA[ fred ]]> </f_name> > ________^tab^_________________^tab^____________ > > so while "preserveWhiteSpace=false" will handle "[ fred ]", the extra tabs are all converted to > their own type3 node, yes? > > thanx > barry.b > > PS: > I've kicked the butt of the guy who wrote the server-side XML. I usually just get a URL (with > params) and that displays the xml doc in IE as my API (for XmlHttpRequest) > > ...and of course the whitespace doesn't show up in the browser directly...D'oh! > > > > > > > > > You"re probably seeing the white space in your XML turned into XML nodes. In XML, > whitespace is > non-trivial and can be included as part of the document as its own node. > > XML for <SCRIPT> provides a way to turn this feature off in the DOMImplementation object. > See > > > http://xmljs.sourceforge.net/website/documentation-w3cdom-DOMImplementation.html#DOMImplementationpreserveWhiteSpace > > for more info. It should be off by default though. Are you turning it on for some reason? > > David > > > > > -----Original Message----- > > From: xml...@li... > > [mailto:xml...@li...]On Behalf Of Barry > > Beattie > > Sent: Wednesday, 13 April 2005 1:31 PM > > To: XmlForJS (E-mail) > > Subject: [xmljs-users] ELEMENT_NODE Vs TEXT_NODE > > > > > > (this list has been so quiet that I'm wondering if I'm still > > subscribed...) > > > > hi all > > > > I'm really stumped on this (partly because I'm trying to > > muddle through this while being unwell) > > > > I've got a bunch of child nodes that are returning > > alternating (and phantom) types (xml below). I've had to > > filter out the "phantoms" with > > > > if(thisPeriod.nodeType == 1) > > > > Tracing the nodeType and length of childNodes I get 15 child > > nodes and their types are > > > > 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3. > > > > I should only have 7 childNodes (7 "periods"). Where have the > > 8 text nodes come from? > > > > thanx > > barry.b > > > > > > periods = > > timetableRoot.getElementsByTagName("periods").item(0).getChildNodes(); > > for(var i=0;i<periods.length;i++){ > > var thisPeriod = periods.item(i) // each child node > > > > if(thisPeriod.nodeType == 1){// "1" = > > DOMNode.ELEMENT_NODE; "3" = DOMNode.TEXT_NODE > > .... process ... > > > > - <periods> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <period currentperiod="NO"> > > + <periods> > > > > > > and each <period> has this layout (note: there are 0 to many subjects) > > > > > > <period currentperiod="NO"> > > <day_code><![CDATA[ 2 ]]></day_code> > > <prd_code><![CDATA[ 1 ]]></prd_code> > > <prd_desc><![CDATA[ Period 1 ]]></prd_desc> > > <prd_end><![CDATA[ {ts '1970-01-01 09:39:00'} ]]></prd_end> > > <prd_start><![CDATA[ {ts '1970-01-01 09:00:00'} ]]></prd_start> > > <prd_weight /> > > <tt_id><![CDATA[ 26 ]]></tt_id> > > <subjects> > > <subject sub_code="0031"> > > <sub_code><![CDATA[ 0031 ]]></sub_code> > > <shortdescription><![CDATA[ Mat1 > > ]]></shortdescription> > > <class><![CDATA[ A ]]></class> > > <room><![CDATA[ B3 ]]></room> > > <sub_desc><![CDATA[ Mathematics I > > ]]></sub_desc> > > <tch_code><![CDATA[ LD ]]></tch_code> > > <tch_name><![CDATA[ Miss L Dent ]]></tch_name> > > </subject> > > </subjects> > > </period> > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from > > real users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick > > _______________________________________________ > > xmljs-users mailing list > > xml...@li... > > https://lists.sourceforge.net/lists/listinfo/xmljs-users > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |