[Xerte] childNodes count?
Dave Burnett
d_b_burnett at hotmail.com
Fri Nov 19 12:05:56 GMT 2010
I agree, I'll change the structure.
I'm just curious now as to how to get the count in an associative array or object.
Most of the AS refs say you have to loop over it (for key in object) ++ type thing.
But I can't get it to work.
Some other day...
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Fri, 19 Nov 2010 11:57:52 +0000
Subject: RE: [Xerte] childNodes count?
It’s the innards of XMLToObject() that creates the 4. I’d not do it your way because you can’t identify your navItems as navItems: they are all different types of node, when really they are different types of navItem. From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 19 November 2010 11:43
To: Xerte list
Subject: RE: [Xerte] childNodes count?
Or I could add count="6" to the navigation tag:
<navigation count="6">
:-)
I do prefer property arrays to index arrays. Way more idiot-proof.
An index array will entail nested loops each time I want to get a value.
I just hate not seeing why this gives me 4:
debug(templateData.brand[0].navigation[0].copy[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].dict[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].open[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].home[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].next[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].back[0].tooltip);//correct
debug(templateData.brand[0].navigation[0].length); //4
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Fri, 19 Nov 2010 11:22:23 +0000
Subject: RE: [Xerte] childNodes count?I’d do this: <brand> <navigation> <navItem swf="btnBack_ease.swf" tooltip="Previous page Shortcut-key: Alt+Left" x="100" y="200" w="100" h="200/> <navItem swf="btnBack_ease.swf" tooltip="Previous page Shortcut-key: Alt+Left" x="100" y="200" w="100" h="200/> <navItem swf="btnBack_ease.swf" tooltip="Previous page Shortcut-key: Alt+Left" x="100" y="200" w="100" h="200/> <navItem swf="btnBack_ease.swf" tooltip="Previous page Shortcut-key: Alt+Left" x="100" y="200" w="100" h="200/></navigation></brand> Then you should be able to get templateData.brand[0].navigation[0].navItem.length From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 19 November 2010 11:13
To: Xerte list
Subject: RE: [Xerte] childNodes count? "Collections" according to Google.
debug(templateData.brand[0].navigation[0].length);
4
I tried that and about 2 dozen other variations.
I variously get undefined, 4 or 9.From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Fri, 19 Nov 2010 08:37:47 +0000
Subject: RE: [Xerte] childNodes count?They are objects (arrays I think), not XML Nodes. Try templateData.brand[0].navigation[0].length; //no childNodes on objects! From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 18 November 2010 20:53
To: Xerte list
Subject: [Xerte] childNodes count?
Here's the structure being read into templateData:
<brand>
<background graphic="intromen_ease.gif" x="0" y="0" w="100" h="200">
</background>
<navigation>
<back swf="btnBack_ease.swf" tooltip="Previous page Shortcut-key: Alt+Left" x="100" y="200" w="100" h="200"></back>
<next swf="btnNext_ease.swf" tooltip="Next page Shortcut-key: Alt+Right" x="200" y="200" w="100" h="200"></next>
<home swf="btnHome_ease.swf" tooltip="Unit home page Shortcut-key: Alt+Home" x="300" y="200" w="100" h="200"></home>
<open swf="btnOpen_ease.swf" tooltip="Open a unit Shortcut-key: Ctrl+O" x="400" y="200" w="100" h="200"></open>
<dict swf="btnDict_ease.swf" tooltip="Show the Dictionary" x="500" y="200" w="100" h="200"></dict>
<copy swf="btnCopy_ease.swf" tooltip="Copy text to your scrapbook" x="600" y="200" w="100" h="200"></copy>
</navigation>
</brand>
inspect(templateData.brand[0].navigation[0])
gives me 6 children:
copy : null
dict : null
open : null
home : null
next : null
back : null
debug(templateData.brand[0].navigation[0].childNodes.length);
gives me 4
fah.
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
_______________________________________________
Xerte mailing list
Xerte at lists.nottingham.ac.uk
http://lists.nottingham.ac.uk/mailman/listinfo/xerte
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20101119/ebe6adcc/attachment.html
More information about the Xerte
mailing list