Bill,
Take a look at kirupa's XML guide here:
http://www.kirupa.com/web/xml/XMLwayAround2.htm
I also came across the same problem some time ago. I decided not to play
with siblings because our xml schema (especially the order of the
sibling nodes) couldn't be predictable. So I went to a custom parsing
process based on the nodeName of each child node of my sibling nodes.
Something like:
var subItemObject:Object = {};
var subItemChildNodes:Array = subItemNode.childNodes;
for (var i:Number = 0; i < subItemChildNodes.length; i++) {
var attributeNode:XMLNode = subItemChildNodes[i];
var attrName:String = attributeNode.nodeName;
var attrValue:String = attributeNode.firstChild.nodeValue;
subItemObject[attrName] = attrValue;
}
Hope it helps,
Julien Vignali
Bill Pelon a écrit :
I'm having trouble grabbing the right value from a node any help would
be awesome.. I can't figure out where to increment as I'm going through
my loop for the sub items.
node structure below --------------------------------------------
<NetworkLeftnav>
<mainItem name="main item name goes here" url="url goes here"
window="_self" open="true">
<subItem>
<text>sub item name goes here</text>
<url>sub item URL goes here</url>
<window>_self</window>
</subItem>
<subItem>
<text>sub item name goes here # 2</text>
<url>sub item URL # 2</url>
<window>_self</window>
</subItem>
</mainItem>
<mainItem name="main item 2" url="main item url #2" window="_self"
open="false">
</mainItem>
</NetworkLeftnav>
AS below --------------------------------------------
onClipEvent(load){
function ExpandData(turbo){
var turboItem = turbo.firstChild.childNodes;
var subItem = turbo.firstChild.firstChild.childNodes;
trace("number of main section nodes" +
turbo.firstChild.childNodes.length); // main section count
for (var i = 0; i < turboItem.length; i++){
var turbo = turboItem[i];
// running through main nodes
mainNavName = turbo.attributes.name;
mainNavUrl = turbo.attributes.url;
mainNavWindow = turbo.attributes.window;
mainNavOn = turbo.attributes.open; // set to true or false
trace("mainNaveName = " + mainNavName);
trace("mainNaveURL = " + mainNavURL);
trace("mainNaveWindow = " + mainNavWindow);
trace("mainNaveOn = " + mainNavOn);
if( turbo.childNodes.length >=1){
trace("this node has subcontent");
trace("number of subcontent nodes = "+ turbo.childNodes.length);
turboChild = turbo.firstChild.firstChild;
trace(" ");
trace("total times to loop = " + turbo.childNodes.length);
for (var n = 0; n < turbo.childNodes.length; n++){
trace("Subcounter incremental value = " + n);
///////////////// THESE NEED TO BE INCRIMENTED????????????
trace(turboChild.firstChild.nodeValue); // returns sub item name
trace(turboChild.nextSibling.firstChild.nodeValue); // returns sub
item URL
trace(turboChild.nextSibling.nextSibling.firstChild.nodeValue); //
returns sub itemWindow
}
}
trace(" ");
}
}
var turbo = new XML();
turbo.ignoreWhite = true;
turbo.onLoad = function(success){
if (success) ExpandData(this);
else trace("Error loading XML file");
}
turbo.load("netnav.xml"); // what my xml is called that is posted above
stop();
}
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com