Solved

ActionScripts 3.0 XML how to count children

Posted on 2011-03-12
5
575 Views
Last Modified: 2012-05-11
Hi,

I need to count hot many childern of a node is in an xml. How do get a count?
Example.
How do I get a count of how many(<a1><a2>....) are in <r>[0] ?

Thanks
<?xml version='1.0' encoding='ISO-8859-1'?>
<note>
  <t1>15:14</t1>
  <t2>2:06:23 PM</t2>
  <t3>2/25/2011</t3>
  <t4>arr</t4>
  <r><r>
<a1>blaa</a1>
<a2></a2>
<a3></a3>
<a4></a4>
</r>
</note>

Open in new window

0
Comment
Question by:Baz487
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35119606
The xml seems to be wrong.

Warm Regards
Deepanjan Das
0
 

Author Comment

by:Baz487
ID: 35119844
true..
I corrected it.
<?xml version='1.0' encoding='ISO-8859-1'?>
<note>
<r>
<a1>blaa</a1>
<a2>111</a2>
<a3>222</a3>
<a4>555</a4>
</r>
</note>

Open in new window

0
 
LVL 4

Expert Comment

by:mawni
ID: 35120366
First you have to load the XML file
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest(“file.xml”));


function loadXML(e:Event):void
{
        xml = new XML(e.target.data);
        trace(xml); // here you can see what nodes and how to parse them
}
0
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 35121240
based on mawni's solution try this:
xml.r.children();

warm regards
Deepanjan Das

0
 

Author Comment

by:Baz487
ID: 35122185

xml.r.children().length()
worked.
Thanks,
Baz
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question