Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 17:40
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  XML + create XMLList from each parent node
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: XML + create XMLList from each parent node  (Read 1314 times)
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« on: 05/20/10, 10:10 »

Hey there-  I have a very simple XML file and need to extract each parent node into it's own XMLList, for later altering.  For example:

XML:
Code:
<treeMenu>
  <item txt="1">
    <item txt="A">
      <item txt="A1"></item>
      <item txt="A2"></item>
    </item>
  </item>
</treeMenu>

How would I capture each "item" parent into it's own xmlList, ignoring any "item" node that does not contain children?  Thanks, any help is appreciated!
« Last Edit: 05/20/10, 10:14 by worked » Logged
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« Reply #1 on: 05/20/10, 11:42 »

Ok, So I've made some headway, but am slightly confused on one thing:
XML:
Code:
<treeMenu>
  <item txt="1">
    <item txt="a">
      <item txt="a1">
        <item txt="a1-1"/>
        <item txt="a1-2"/>
      </item>
      <item txt="a2">
        <item txt="a2-1">
          <item txt="a2-a1">
            <item txt="a2-a2"/>
          </item>
        </item>
      </item>
    </item>
  </item>
</treeMenu>

With the above xml file, I'm able to decipher which nodes contain Complex Content, which in-turn gives me every parent node in the file. However, for some reason when I trace those Booleans i receive "false" for any parent node that contains only one child.  Here's my code:

AS3:
Code:
var btnXML:XML = new XML(e.target.myXML);
var btnList:XMLList = btnXML..button;
for each(btnXML in btnList){
  trace(btnXML.@id + " - " + btnXML.button.hasComplexContent());
}
trace output:
1 - true
a - true
a1 - true
a1-1 - false
a1-2 - false
a2 - true
a2-1 - true
a2-a1 - false : should be true
a2-a2 - false
« Last Edit: 05/20/10, 11:43 by worked » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #2 on: 05/20/10, 12:41 »

try to avoid the dash, it might be seen as operator for subtration Wink - and after you have a non numeric value first, it will be false, because you cannot subtract a number from a string.
Logged

happy flashing
Cool
Ronald
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« Reply #3 on: 05/22/10, 05:44 »

Thanks for responding!  I kept digging deeper and found the issue... thanks though!
« Last Edit: 05/24/10, 20:39 by worked » Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything