Title: CSC 2720 Building Web Applications
1CSC 2720Building Web Applications
- Flex
- ECMAScript for XML (E4X)
2ECMAScript for XML (E4X)
- 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 employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
4 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees.employee0.address.zip
- or
- employees.employee0.address'zip'
- 1st employee element ? all address elements ? all
zip elements of each address element
5 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees.employee1._at_ssn
- or
- employees.employee1._at_'ssn'
- 2nd employee element ? attribute ssn
6 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees.employee.name
- All employee elements ? all name elements of each
employee element
7 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees..zip0
- Root element ? first zip element that is a
descendent
8 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees.._at_ssn1
- Root element ? 2nd ssn attribute among the
descendents
9 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- employees.employee0.address.
- 1st employee element ? all address elements ? all
immediate child elements
10 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- var sString ''
- for each (var numXML in employees.._at_ssn)
- s (num) " "
-
- // s becomes "123-123-1234 789-789-7890 "
11 public var employeesXML
ltemployeesgt ltemployee
ssn"123-123-1234"gt ltname
first"John" last"Doe"/gt
ltaddressgt ltstreetgt11
Main St.lt/streetgt
ltcitygtSan Franciscolt/citygt
ltstategtCAlt/stategt
ltzipgt98765lt/zipgt
lt/addressgt lt/employeegt
ltemployee ssn"789-789-7890"gt
ltname first"Mary" last"Roe"/gt
ltaddressgt
ltstreetgt99 Broad St.lt/streetgt
ltcitygtNewtonlt/citygt
ltstategtMAlt/stategt
ltzipgt01234lt/zipgt
lt/addressgt lt/employeegt
lt/employeesgt
- var ssnToFindString "789-789-7890"
- employees.employee.(_at_ssn ssnToFind).toXMLStrin
g() - Select all employee elements ? Retain only those
with attribute ssn equals to "789-789-7890" ? Get
the XML representation of the selected elements
12(No Transcript)
13References and Resources
- ActionScript 3.0 Language and Components
Reference XML - http//livedocs.adobe.com/flash/9.0/ActionScriptLa
ngRefV3/XML.html - ActionScript 3.0 library for several basic
utilities - http//code.google.com/p/as3corelib/