Here is a full example:

http://www.cflex.net/showFileDetails.cfm?ObjectID=554

 

When doing e4x expressions, do them one step at a time:

var xlSearch:XMLList = xml..folder; //.. means same as descendants, all
in tree

trace(xlSearch.toXMLString())

xlSearch = xml..folder.(attribute("label")=="Getting Started");
//hardcode to simplify. attribute() method is safer than @

trace(xlSearch.toXMLString()); //right node?

xlSearch = xml..folder.(attribute("label")==topicString);

var xmlSearch:XML = xlSearch[0];  //Get an XML node from the XMLList

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason
Sent: Thursday, July 17, 2008 1:16 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Expanding Tree Node Based On Attribute Match

 

Pretty simple question I think, I'm just stuck, it's probably more of 
an E4X XML question. I'm trying to write a method that will expand 
the node of a tree based on a string match. The xml has an attribute 
label, so where that matches the string, open that node of the tree. 
The main bulk of my question I think lies in how I am returning the 
node where the label attribute matches the string. 

First, this doesn't seem to work, this is my lame attempt to find the 
matching node: xml.menuTree.*.(@label == topicString), meaning, look 
for any of the sub nodes where the label attribute matches the string.

Here is my actionscript and xml dataprovider for the tree:

navTree.expandItem(xml.menuTree.*.(@label == topicString), true, 
true); 

var xml:XML = <veniceHelp>
<menuTree>
<folder label="Getting Started">
<folder label="About Venice" />
<folder label="Overview" />
<folder label="Logging In"/>
</folder>
<folder label="The Venice User Interface">
<folder label="The My Profile View" />
<folder label="Viewing A Selected User's 
Profile" />
<folder label="The Network View" />
</folder>
<folder label="Putting Venice To Work">
<folder label="Adding Associates To Your 
Network" />
<folder label="Your Profile" >
<folder label="Editing Your Profile" 
topic="Edit Profile">
<folder label="Changing Your 
Picture" />
<folder label="Changing Your 
Description" />
<folder label="Changing Your 
Personal Information" topic="Changing Your Personal Information" />
</folder>
</folder>
<folder label="Skills">
<folder label="Adding Skills" 
topic="Add Skill" />
<folder label="Editing Skills" 
topic="Edit Skill" />
<folder label="Marking All Skills As 
Private" topic="Marking All Skills As Private" />
</folder>
</folder>
<folder label="Support"/>
</menuTree>
</veniceHelp>

 

Reply via email to