Solved

ActionScripts 3.0 XML how to count children

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xslt copy xml document for each occurance of a repeating node 4 12
Mongodb hierarchy 2 44
tag a picture in Word 2013? 6 46
Test ddwrt:UserLookup 1 52
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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…
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 how to how to load their YouTube profile onto Flash Media Live Encoder.

929 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