ECMAScript for XML


ECMAScript for XML is the standard ISO/IEC 22537:2006 programming language extension that adds native XML support to ECMAScript. The goal is to provide an alternative to DOM interfaces that uses a simpler syntax for accessing XML documents. It also offers a new way of making XML visible. Before the release of E4X, XML was always accessed at an object level. E4X instead treats XML as a primitive. This implies faster access, better support, and acceptance as a building block of a program.
E4X is standardized by Ecma International in the . The first edition was published in June 2004, the second edition in December 2005.
The E4X standard was deprecated by the Mozilla Foundation in 2014.

Browser support

E4X is supported by Mozilla's Rhino, used in OpenOffice.org and several other projects. It is also supported by Tamarin, the JavaScript engine used in the Flash virtual machine. It is not supported by other common engines like Nitro, V8, Carakan, Chakra and Chakra.
E4X was also supported by SpiderMonkey, but has been removed. In Firefox 10, E4X syntax was no longer accepted in SpiderMonkey when ECMAScript 5 "strict mode" is enabled. According to Brendan Eich, "This thus signals start of deprecation for E4X in SpiderMonkey." and "has been disabled by default for webpages in Firefox 17, disabled by default for chrome in Firefox 20, and has been removed in Firefox 21"

Example


var sales =



;
alert;
alert;
for each
delete sales.item;
sales.item += ;
sales.item..@quantity = 4;

Implementations

The first implementation of E4X was designed by Terry Lucas and John Schneider and appeared in BEA's Weblogic Workshop 7.0 released in February 2002. BEA's implementation was based on Rhino and released before the ECMAScript E4X spec was completed in June 2004. John Schneider wrote an on the XML extensions in BEA's Workshop at the time.