ECMAScript for XML: E4X
E4X stands for “ECMAScript for XML” and ECMA in turn stands for European Computer Manufacturers Association. ECMAScript for XML (E4X) is a programming language extension that adds native XML support to ECMAScript. It is the next gen of Scripting Language.
ECMA is the standardizing and organization JavaScript. ECMA has also developed standards for quite a few stuffs apart from JavaScript e.g. Optical disks, Magnetic tape and C# language etc.
E4X is available to both Firefox and ActionScript developers that turns XML into a native data type on par with strings, arrays, objects, and regular expressions. Worth to mention its not the DOM equivalent of XML but is a distinct entity itself which has its own set of methods. E4X is implemented in SpiderMonkey (Gecko’s JavaScript engine) and in Rhino (JavaScript engine written in Java).
Why work with E4X when you can do the same thing with JSON objects?
JSON is marginally more compact to encode— than for attribute intensive XML or element heavy encodings. But this advantage disappears if the resource is gzipped as for both the cases we are storing labels and associated values. Thus if transmission is concerned then gzipping the content will occur as a matter of fact and the speed becomes insignificant comparison. Apart from this some very interesting work is going on with EXI (i.e. Efficient XML Interchange) that to at W3C level that is trying to make EXI more compact than even compressed JSON.
Key features of E4X include:
- ECMAScript for XML specification defines a new set of classes and functionality for working with XML data.
- E4X can be used for creating templates for dynamic content.
- Using E4X functionality is much easier and more intuitive than “walking the DOM”.
- You manipulate XML data with well-known operators, such as the dot (.) operator.
- Use the @ and (.) operators not only to read data, but also to assign data.
Limitations of E4X:
- E4X doesn’t support parsing XML declaration
- It is not currently possible to access a DOM object through E4X.
Latest posts by rupak
- How to Theme profile2 module form - September 22nd, 2011
- How to render Map inside jquery tabs on tab click - August 24th, 2011
- Front-end page optimization - August 3rd, 2011
- Why we use Subversion (SVN) in web development - June 30th, 2011
Tags: javascript
