Solved

ActionScripts 3.0 XML how to count children

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

786 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