XML - E4X
document.write(employees.person.(name == "Tove").age);
This example works in Firefox only!
With E4X, you can declare an XML object variable the same way as you declare a Date or an Array object variable:
var y = new Date()
var z = new Array()
The ECMA organization (founded in 1961) is dedicated to the standardization of Information and Communication Technology (ICT) and Consumer Electronics (CE). ECMA has developed standards for:
- C# Language
- International Character Sets
- Optical Disks
- Magnetic Tapes
- Data Compression
- Data Communication
- and much more...
The following example is a cross browser example that loads an existing XML document ("note.xml") into the XML parser and displays the message from the note:
//code for Internet Explorer
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
// code for Mozilla, Firefox, etc.
else (document.implementation && document.implementation.createDocument)
Try it yourself »
The following example is the same as above but using E4X:
Much simpler, isn't it?
Firefox is currently the only browser with relatively good support for E4X.
There are currently no support for E4X in Opera, Chrome, or Safari.
So far there is no indication for of E4X support in Internet Explorer.
The Future of E4X
E4X is not widely supported. Maybe it offers too little practical functionality not already covered by other solutions:
- For full XML processing, you still need the XML DOM and XPath
- For accessing XMLHttpRequests, JSON is the preferred format.
- For easy document handling, JQuery selectors are easier.
Thank You For Helping Us!
Your message has been sent to W3Schools.