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.



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:

 <p>This example works in Firefox only.</p>
 <table border=1>
 <!-- E4X  START -->
    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"/>
    for each( var item in sales.item) {
      document.write( '<tr><td>' + item.@type + '<td>' + item.@price + '</td><td>' + item.@quantity + '</td></tr>' );
 <!-- E4X  END -->

(You can find some other examples at Wikipedia's E4X entry)[1]



External Links


  1. wikipedia: ECMAScript for XML

See Also

JavaScript | ActionScript | XML