@ operator has the attribute() and attributes() methods for accessing attributes by name or as an XML list respectively. : at « XML « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » XML » at 
@ operator has the attribute() and attributes() methods for accessing attributes by name or as an XML list respectively.
 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var movieList:XML = <movieList>
                                <listName>My favorite movies</listName>
                                <movie id="123">
                                    <title>Titus</title>
                                    <year>1999</year>
                                    <director>J T</director>
                                </movie>
                                <movie id="456">
                                    <title>Rushmore</title>
                                    <year>1998</year>
                                    <director>W A</director>
                                </movie>
                                <movie id="789">
                                    <title>Hall</title>
                                    <year>1977</year>
                                    <director>Woody Allen</director>
                                </movie>
                           </movieList>;
        
        movieList.movie[1].attribute("id")// 456
        movieList.movie[2].attributes()// 789
        //The preceding code is functionally identical to the following code:
        movieList.movie[1].@id; // 456
        movieList.movie[2].@*; // 789


    }
  }
}

        
Related examples in the same category
1. Use E4X to dot down to the particular element node, and then use the @ operator followed by the attribute's name to access its value
2. Use a wildcard (*) with the @ operator to access all attributes of an element
3. Use E4X to total the prices of all of the elements with a price attribute
4. To access all of the attributes for a tag, you can use an asterisk
5. Use bracket to access an attribute by name, or when the attribute name contains characters not allowed in variable names
6. Reference third level tag value
7. Deleting Elements and Attributes: To remove an element or attribute from a document, use the delete operator as follows: delete elementOrAttribute
ww___w__.ja_v__a2__s_.c__o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.