CSC 2720 Building Web Applications - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CSC 2720 Building Web Applications

Description:

CSC 2720 Building Web Applications Flex ECMAScript for XML (E4X) ECMAScript for XML (E4X) A programming language extension that adds native XML support to ECMAScript ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 14
Provided by: cjy6
Category:

less

Transcript and Presenter's Notes

Title: CSC 2720 Building Web Applications


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

2
ECMAScript 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)
13
References 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/
Write a Comment
User Comments (0)
About PowerShow.com