Solved

ActionScripts 3.0 XML how to count children

Posted on 2011-03-12
5
537 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now