[xmljs-users] ELEMENT_NODE Vs TEXT_NODE
Brought to you by:
djoham,
witchhunter
|
From: Barry B. <Ba...@al...> - 2005-04-13 03:32:09
|
(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=20
if(thisPeriod.nodeType =3D=3D 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.=20
I should only have 7 childNodes (7 "periods"). Where have the 8 text =
nodes come from?
thanx
barry.b
periods =3D =
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 DOMNode.ELEMENT_NODE; =
"3" =3D DOMNode.TEXT_NODE
.... process ...
- <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>
and each <period> has this layout (note: there are 0 to many subjects)
<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 ]]></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>
|