ECMAScript for XML Guide and Resources

ECMAScript for XML, which is usually referred to as E4X, was designed to make XML data easier to work with.

While you may not be very familiar with ECMAScript you've certainly heard of it's most popular implementation: JavaScript.

In effect, E4X is a bolt-on extension for JavaScript that adds native support for XML data much in the same way that JavaScript includes native support for JSON format data.

While E4X never enjoyed broad adoption and has been removed from all modern browsers, it is still used in some Flash other Adobe products.

What is E4X?

Right now you may be thinking to yourself: "But, JavaScript can be used to access XML data!" And if you had that thought, congratulations, you're right! However, there's a big difference between the way XML data is accessed with JavaScript and the way XML data is accessed with E4X.

Modern JavaScript can be used to traverse the XML DOM. This means that the XML data exists as a separate entity and JavaScript can be used to interact with that data.

However, the data itself always remains a separate entity — a resource used by a script — rather than becoming part of the script itself.

E4X, on the other hand, makes it possible to import or create XML data in JavaScript and treat it as a primitive data type. This means that the XML data is actually part of the script itself and can be manipulated much in the same way that other data types such as arrays, strings, and objects, can be manipulated.

In short, E4X makes working with XML data a much more flexible process and speeds up the parsing of data since it exists as a primitive data type rather than an external resource.

E4X sounds pretty great, right? If you use XML on a regular basis you might be wondering why E4X isn't supported natively by every browser. To figure out what happened to E4X, let's go to the tape.

History of E4X

E4X was originally developed at BEA Systems by Terry Lucas and John Schneider, and implemented for the first time in BEA WebLogic Platform 7.0 in 2002.

This actually predated the formal completion of the E4X specification, which was released more than two years later in 2004. Shortly thereafter, E4X was implemented by Firefox and support was also added to Adobe's ActionScript 3.

Despite this early adoption, E4X implementation was uneven and inconsistent. Brendan Eich, creator of JavaScript and founder of Mozilla, has been quoted as saying that "E4X is crazyland".

In addition, Mark S Miller, a research scientist at Google, observed that the Firefox implementation of E4X deviated "from the (official E4X) spec in ways that are not written down anywhere."

Another factor that may have contributed to the lukewarm acceptance of E4X was the concurrent development of JSON.

JSON solved many of the same problems that E4X attempted to solve with XML, but JSON solved them without requiring a bolt-on ECMAScript extension and without the consistency issues that plagued E4X.

In other words, while E4X enjoyed early adoption by Firefox and Adobe, it was never consistently implemented and lost out to rivals such as JSON. As a result, browser support never expanded beyond Firefox.

Since E4X support was added to ActionScript 3, support for E4X had to be built into every Adobe application that implements ActionScript 3. As a result, E4X does live on in Adobe products.

Browser Support for E4X

While E4X was at one time supported by Firefox, support was deprecated in Firefox version 16 in October of 2012 and subsequently removed from Firefox in version 18 in January of 2013.

Today, E4X isn't supported by any of the JavaScript engines behind leading browsers such as Safari (Nitro engine), Chrome (V8 engine), or Microsoft browsers Internet Explorer and Edge (both use Chakra).

However, as we mentioned, E4X is integrated into ActionScript 3, which is the the Adobe Flash flavor of ECMAScript. As a result, JavaScript engines associated with Flash, such as Rhino and Tamarin, do support E4X.

However, neither of these engines is used by popular consumer web browsers. In other words, you might be able to use E4X is you're writing a Flash application, but for general-purpose web programming, stick to standard JavaScript to traverse the XML DOM and skip the E4X extension.

Modern E4X Application

If you need to learn more about E4X, there's a good chance it's because you're going to be using it for an Adobe Flash application. E4X's most visible modern use occurs within the Adobe Flash ecosystem.

E4X is implemented in ActionScript 3 and supported by several modern Adobe products including Flash CS3, Adobe AIR, Adobe Flex, Adobe Acrobat, and Adobe Reader. However, non-Adobe implementation of E4X is virtually nonexistent.

E4X Resources

If you already know ActionScript or JavaScipt, learning how to manipulate XLM data with E4X won't be hard. E4X is just a bolt-on component for the ECMAScript rendering engine. As a result, all you'll need to do is learn the XML-specific functions and you'll be ready to roll.

Most E4X resources are fairly dated. However, since development of E4X is not ongoing, these dated resources are still accurate and useful. We've tracked down some of the best E4X resources so that you can learn what you need to know to manipulate XML data with E4X and ActionScript.


E4X was a good idea that was inconsistently implemented and beat out by competing technologies. However, it lives on in products that support ActionScript 3 and is supremely useful for creating and manipulating XML data with ECMAScript.

Further Reading and Resources

We have more guides, tutorials, and infographics related to coding and website development:

What Code Should You Learn?

Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn?

It not only discusses different aspects of the languages, it answers important questions such as, "How much money will I make programming Java for a living?"