E4X

From BC$ MobileTV Wiki
Jump to: navigation, search

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.


Specifications


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


External Links


References

  1. wikipedia: ECMAScript for XML


See Also

JavaScript | ActionScript | XML