RE: [xmljs-users] ELEMENT_NODE Vs TEXT_NODE
Brought to you by:
djoham,
witchhunter
From: Barry B. <Ba...@al...> - 2005-04-15 05:02:16
|
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.=20 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=3Dfalse" will handle "[ fred ]", the extra = tabs are all converted to their own type3 node, yes? thanx barry.b PS:=20 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. =20 XML for <SCRIPT> provides a way to turn this feature off in the = DOMImplementation object. See =20 http://xmljs.sourceforge.net/website/documentation-w3cdom-DOMImplementati= on.html#DOMImplementationpreserveWhiteSpace =20 for more info. It should be off by default though. Are you turning it = on for some reason? =20 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 >=20 >=20 > (this list has been so quiet that I'm wondering if I'm still=20 > subscribed...) >=20 > hi all >=20 > I'm really stumped on this (partly because I'm trying to=20 > muddle through this while being unwell) >=20 > I've got a bunch of child nodes that are returning=20 > alternating (and phantom) types (xml below). I've had to=20 > filter out the "phantoms" with=20 >=20 > if(thisPeriod.nodeType =3D=3D 1) >=20 > Tracing the nodeType and length of childNodes I get 15 child=20 > nodes and their types are >=20 > 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3.=20 >=20 > I should only have 7 childNodes (7 "periods"). Where have the=20 > 8 text nodes come from? >=20 > thanx > barry.b >=20 >=20 > periods =3D=20 > timetableRoot.getElementsByTagName("periods").item(0).getChildNodes(); > for(var i=3D0;i<periods.length;i++){ > var thisPeriod =3D periods.item(i) // each child node > =20 > if(thisPeriod.nodeType =3D=3D 1){// "1" =3D =20 > DOMNode.ELEMENT_NODE; "3" =3D DOMNode.TEXT_NODE > .... process ... >=20 > - <periods> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <period currentperiod=3D"NO"> > + <periods> >=20 >=20 > and each <period> has this layout (note: there are 0 to many subjects) >=20 >=20 > <period currentperiod=3D"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 />=20 > <tt_id><![CDATA[ 26 ]]></tt_id> > <subjects> > <subject sub_code=3D"0031"> > <sub_code><![CDATA[ 0031 ]]></sub_code> > <shortdescription><![CDATA[ Mat1 =20 > ]]></shortdescription> > <class><![CDATA[ A ]]></class> > <room><![CDATA[ B3 ]]></room> > <sub_desc><![CDATA[ Mathematics I =20 > ]]></sub_desc> > <tch_code><![CDATA[ LD ]]></tch_code> > <tch_name><![CDATA[ Miss L Dent ]]></tch_name> > </subject> > </subjects> > </period> >=20 >=20 > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from=20 > real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_ide95&alloc_id=14396&op=3Dick > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users >=20 |