[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/13/2009 at 04:35AM PDT, ID: 24404270
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Flex Tree from Complex XML

Asked by enjay99 in Adobe Flex

Tags: Flex 3 Tree XML

Hi Genius'

I have been struggling with this for about a week now so it is time to ask for some help.
I have a well formed XML file that I receive from a server (please see original.xml) and I would like to represent it as a tree that the user can click on a leaf and be able to edit the elements associated with that item in fields to the right of the tree (either a dataGrid or a series of textInput fields.)

My problem is how to get it into a tree and tightly bound to the XML.

All of the examples that I have found mysteriously change from xml with elements in it into XML with only attributes (something like tree_1.xml). This is not useful as the actual data I am using has many elements attached to each leaf and sometimes multiple attributes.

My gut feeling (with very little experience in these matters) is to reformat the original.xml into a tree structure (like tree_2.xml), bind it to an XMLListCollection and create a tree by using a labelFunction.

I have two problems with this approach:

    1. XMLListCollection does not seem to like the tree structure XML
    2. If I write a labelFunction like:

private function getTreeLabel(item:Object):String
            {
                var node:XML = XML(item);
                if( node.localName() == "Desc" )
                    return node;
               else
                   return null;
            }

I can do this by using the HTTPService as the dataProvider I get the branches and leaves I want but I also get a blank tree item for each of the nulls

I hope I have described the problem clearly as it is now very late here.
Going around in circles and very tired, so any help would be much appreciated.

Best Regards,





1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
original.xml
 
<treeID>103</treeID>
<treeType>Oak</treeType>
<branches>
    <branch>
        <id label="branch ID" dbid="0">290</id>
        <branchCode label="branch Code" dbid="1">A</branchCode>
        <branchTitle label="Title" dbid="2">Small Branch</branchTitle>
    </branch>
    <branch>
        <id label="branch ID" dbid="0">391</id>
        <branchCode label="branch Code" dbid="1">B</branchCode>
        <branchTitle label="Title" dbid="2">Big Branch</branchTitle>
    </branch>
</branches>
 
<leaves>
    <leaf>
        <id label="leaf ID" dbid="0">48</id>
        <leafCode label="leaf Code" dbid="1">xBBLeaf1</leafCode>
        <leafDesc label="leaf Description" dbid="3">Big Branch Leaf One</leafDesc>
        <onbranchs label="Appear on branchs" dbid="5">B</onbranchs>
        <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
        <leafSize label="Leaf Size" dbid="10">123</leafSize>
    </leaf>
    <leaf>
        <id label="leaf ID" dbid="0">138</id>
        <leafCode label="leaf Code" dbid="1">yBBLeaf2</leafCode>
        <leafDesc label="leaf Description" dbid="3">Big Branch Leaf Two</leafDesc>
        <onbranchs label="Appear on branchs" dbid="5">B</onbranchs>
        <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
        <leafSize label="Leaf Size" dbid="10">124</leafSize>
    </leaf>
    <leaf>
        <id label="leaf ID" dbid="0">49</id>
        <leafCode label="leaf Code" dbid="1">Unileaf</leafCode>
        <leafDesc label="leaf Description" dbid="3">The Multi Leaf</leafDesc>
        <onbranchs label="Appear on branchs" dbid="5">AB</onbranchs>
        <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
        <leafSize label="Leaf Size" dbid="10">125</leafSize>
    </leaf>
    <leaf>
        <id label="leaf ID" dbid="0">44</id>
        <leafCode label="leaf Code" dbid="1">SBLeaf1</leafCode>
        <leafDesc label="leaf Description" dbid="3">Small Branch Leaf One</leafDesc>
        <onbranchs label="Appear on branchs" dbid="5">A</onbranchs>
        <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
        <leafSize label="Leaf Size" dbid="10">126</leafSize>
    </leaf>
    <leaf>
        <id label="leaf ID" dbid="0">42</id>
        <leafCode label="leaf Code" dbid="1">SBLeaf2</leafCode>
        <leafDesc label="leaf Description" dbid="3">Small Branch Leaf Two</leafDesc>
        <onbranchs label="Appear on branchs" dbid="5">A</onbranchs>
        <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
        <leafSize label="Leaf Size" dbid="10">127</leafSize>
    </leaf>
</leaves>
 
=================================================================
 
tree_1.xml
 
<tree>
<branches>
    <branch id="290" branchCode="A" label="Small Branch" />
        <leaves>
            <branch id="44" leafCode="xSBLeaf1" label="Small Branch Leaf One" />
            <branch id="42" leafCode="xSBLeaf1" label="Small Branch Leaf Two" />
            <branch id="49" leafCode="Uni" label="The Multi Leaf" />
        </leaves>
    </branch>
    <branch id="391" branchCode="B" label="Big Branch" />
        <leaves>
            <branch id="48" leafCode="xBBLeaf1" label="Big Branch Leaf One" />
            <branch id="138" leafCode="xBBLeaf1" label="Big Branch Leaf Two" />
            <branch id="49" leafCode="Uni" label="The Multi Leaf" />
        </leaves>
    </branch>
</branches>
</tree>
 
====================================================================
 
 
<tree>
<branches>
    <branch id label="branch ID" dbid="0">290</id>
        <branchCode label="branch Code" dbid="1">A</branchCode>
        <Desc label="Title" dbid="2">Small Branch</branchTitle>
        <leaves>
            <leaf>
                <id label="leaf ID" dbid="0">49</id>
                <leafCode label="leaf Code" dbid="1">Unileaf</leafCode>
                <Desc label="leaf Description" dbid="3">The Multi Leaf</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">AB</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">125</leafSize>
            </leaf>
            <leaf>
                <id label="leaf ID" dbid="0">44</id>
                <leafCode label="leaf Code" dbid="1">SBLeaf1</leafCode>
                <Desc label="leaf Description" dbid="3">Small Branch Leaf One</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">A</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">126</leafSize>
            </leaf>
            <leaf>
                <id label="leaf ID" dbid="0">42</id>
                <leafCode label="leaf Code" dbid="1">SBLeaf2</leafCode>
                <Desc label="leaf Description" dbid="3">Small Branch Leaf Two</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">A</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">127</leafSize>
            </leaf>
        </leaves>
    </branch>
    <branch>
        <id label="branch ID" dbid="0">391</id>
        <branchCode label="branch Code" dbid="1">B</branchCode>
        <Desc label="Title" dbid="2">Big Branch</branchTitle>
        <leaves>
            <leaf>
                <id label="leaf ID" dbid="0">48</id>
                <leafCode label="leaf Code" dbid="1">xBBLeaf1</leafCode>
                <Desc label="leaf Description" dbid="3">Big Branch Leaf One</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">B</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">123</leafSize>
            </leaf>
            <leaf>
                <id label="leaf ID" dbid="0">138</id>
                <leafCode label="leaf Code" dbid="1">yBBLeaf2</leafCode>
                <Desc label="leaf Description" dbid="3">Big Branch Leaf Two</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">B</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">124</leafSize>
            </leaf>
            <leaf>
                <id label="leaf ID" dbid="0">49</id>
                <leafCode label="leaf Code" dbid="1">Unileaf</leafCode>
                <Desc label="leaf Description" dbid="3">The Multi Leaf</leafDesc>
                <onbranchs label="Appear on branchs" dbid="5">AB</onbranchs>
                <leafDate label="Leaf Date" dbid="7">12-04-09</leafDate>
                <leafSize label="Leaf Size" dbid="10">125</leafSize>
            </leaf>
        </leaves>        
    </branch>
</branches>
</tree>
[+][-]05/13/09 05:42 AM, ID: 24374086

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/14/09 01:10 AM, ID: 24382573

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/14/09 04:55 AM, ID: 24383827

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Adobe Flex
Tags: Flex 3 Tree XML
Sign Up Now!
Solution Provided By: mplord
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05/14/09 10:55 PM, ID: 24392597

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/14/09 11:00 PM, ID: 24392617

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/15/09 02:48 AM, ID: 24393668

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625