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.
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