Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-06-2012, 06:58 PM   #1
laurence485
Senior Member
 
Join Date: May 2010
Location: London, UK
Posts: 100
Send a message via MSN to laurence485
Default Get tagnames of XML elements

hi,
what i want to do is get the tag names of all the XML elements with the attribute name="fantasy" for example:
Code:
<books>
<book>
<book1 name="adfasfd2"></book1>
<book2 name="fantasy"></book2>
<book3 name="fantasy"></book3>
<book4 name="hello123"></book4>
</book>
</books>
i.e. i would like to trace "book2" and "book3"

thanks for any help
laurence485 is offline  
Old 03-06-2012, 07:14 PM   #2
dmb85
Senior Member
 
Join Date: Jan 2012
Posts: 608
Default

There's probably a more succinct way of writing this, but this should work:

ActionScript Code:
for each( var element:XML in xml.book.children() ){    if(element.@name == 'fantasy') {       trace( 'element name:' + element.name() );    } }
dmb85 is offline  
Old 03-06-2012, 08:59 PM   #3
laurence485
Senior Member
 
Join Date: May 2010
Location: London, UK
Posts: 100
Send a message via MSN to laurence485
Default

thanks, that is what was needed!
laurence485 is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:31 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.