Try this:
var xmlStr:XML = new XML(str);
Alert.show(xmlStr.descendants.length().toString());

HTH,

-Ravi

On Aug 6, 2:18 pm, Preetham Hegde <preethamheg...@gmail.com> wrote:
> Hi Adrian,
>
> Say for a given xml we can find the count using its inbuilt method *length()
> *
>
> Find a example, may help u..
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>     layout="absolute" creationComplete="initApp()">
>     <mx:Script>
>         <![CDATA[
>             import mx.controls.Alert;
>
>             private var str:String =
> "<page><header>HEADER-1</header><body>BODY-1</body><header>HEADER-2</header><body>BODY-2</body></page>";
>
>             private function initApp():void{
>                 var xmlStr:XML = new XML(str);
>                 Alert.show(xmlStr.body.length().toString());
>
>             }
>         ]]>
>     </mx:Script>
>
> </mx:Application>
>
>
>
> On Thu, Aug 6, 2009 at 9:04 AM, adrianwonder <adria...@gmail.com> wrote:
>
> > Hi everyone
>
> > does anybody knw how to count the number of tags from a XML file? for
> > example...
>
> > <page>
> > <header>HEADER-1
> > </header>
> > <body>
> > BODY-1
> > </body>
> > <header>
> > HEADER-2
> > </header>
> > <body>
> > BODY-2
> > </body>
> > </page>
>
> > If we wanted to count the number of body tags from this XMl file using
> > flex, we should get the result 2.
>
> > Any ideas or suggestions?
>
> > Adrian
>
> --
> Regards,
> Preetham Hegde
> _______________________________________________
> But surely for everything you love you have to pay some price.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to flex_india@googlegroups.com
To unsubscribe from this group, send email to 
flex_india+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to