E4X
From BC$ MobileTV Wiki
ECMAscript For XML (commonly abbreviated as E4X) is an extension that adds native XML support to ECMAScript (which includes ActionScript, DMDScript, JavaScript, and JScript) using a simpler, more efficient access mechanism than the object-based DOM. E4X is currently supported by Mozilla's FireFox browser only.
Contents
Specifications
- ECMAScript for XML (E4X) Specification: http://www.ecma-international.org/publications/standards/Ecma-357.htm
Example
To see E4X in action, copy & paste the following code (in a Firefox browser only) at the Tryit Editor then click the "Edit and Click Me >>" button:
<html> <body> <p>This example works in Firefox only.</p> <table border=1> <tr><th>ITEM</th><th>PRICE</th><th>Qty.</th></tr> <!-- E4X START --> <script> var sales = <sales vendor="John"> <item type="peas" price="4" quantity="6"/> <item type="carrot" price="3" quantity="10"/> <item type="chips" price="5" quantity="3"/> </sales>; for each( var item in sales.item) { document.write( '<tr><td>' + item.@type + '<td>' + item.@price + '</td><td>' + item.@quantity + '</td></tr>' ); } </script> <!-- E4X END --> </table> </body> </html>
(You can find some other examples at Wikipedia's E4X entry)[1]
Resources
Tutorials
- AJAX and scripting web services with E4X, Part 2: http://www.ibm.com/developerworks/xml/library/ws-ajax2/
External Links
- wikipedia: ECMAScript
- Mozilla Developer center - E4X (FireFox's implementation): https://developer.mozilla.org/en/E4X
- Mozilla Developer center - E4X for templating: https://developer.mozilla.org/en/E4X_for_templating
- Wither E4X?: http://www.theopensourcery.com/keepopen/2010/whither-e4x/
References