Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 2720 Building Web Applications Flex ECMAScript for XML (E4X)

Similar presentations


Presentation on theme: "CSC 2720 Building Web Applications Flex ECMAScript for XML (E4X)"— Presentation transcript:

1 CSC 2720 Building Web Applications Flex ECMAScript for XML (E4X)

2  A programming language extension that adds native XML support to ECMAScript  Treats XML as a primitive type (instead of as an object)

3 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;

4 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees.employee[0].address.zip or  employees.employee[0].address['zip']  1 st employee element  all address elements  all zip elements of each address element

5 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees.employee[1].@ssn or  employees.employee[1].@['ssn']  2 nd employee element  attribute ssn

6 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees.employee.name  All employee elements  all name elements of each employee element

7 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees..zip[0]  Root element  first zip element that is a descendent

8 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees..@ssn[1]  Root element  2 nd ssn attribute among the descendents

9 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ;  employees.employee[0].address.*  1 st employee element  all address elements  all immediate child elements

10 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ; var s:String = ''; for each (var num:XML in employees..@ssn) { s += (num) + " "; } // s becomes "123-123-1234 789-789-7890 "

11 public var employees:XML = 11 Main St. San Francisco CA 98765 99 Broad St. Newton MA 01234 ; var ssnToFind:String = "789-789-7890"; employees.employee.(@ssn == ssnToFind).toXMLString() Select all employee elements  Retain only those with attribute ssn equals to "789-789-7890"  Get the XML representation of the selected elements

12

13 References and Resources  ActionScript 3.0 Language and Components Reference – XML  http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/XML.html http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/XML.html  ActionScript 3.0 library for several basic utilities  http://code.google.com/p/as3corelib/ http://code.google.com/p/as3corelib/


Download ppt "CSC 2720 Building Web Applications Flex ECMAScript for XML (E4X)"

Similar presentations


Ads by Google