Re: [xmljs-users] ELEMENT_NODE Vs TEXT_NODE
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2005-04-13 05:10:40
|
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 --- Barry Beattie <Ba...@al...> wrote: > (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=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |