Hi Preetham, I did not try executing it. But yes, there was an error from me. Actually i wanted to write Alert.show(xmlStr.descendants('*').length().toString());
which will return all the descendants of the XML. In your case it returns 8. Apologies for the error. -Ravi On Aug 6, 2:53 pm, Preetham Hegde <preethamheg...@gmail.com> wrote: > Hi Ravi, > > did u check the result. Its 0! > Which length does this xmlStr.descendants.length() must give? > > > > On Thu, Aug 6, 2009 at 3:05 PM, Ravi Mishra <ravi.achi...@gmail.com> wrote: > > > 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. > > -- > Regards, > Preetham Hegde > 9844244834 > > _______________________________________________ > 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 -~----------~----~----~----~------~----~------~--~---