Solved

ActionScripts 3.0 XML how to count children

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

749 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