XML E4X
E4X JavaScript to add direct support for XML.
E4X Examples
<employees>
<person>
<name>Tove</name>
<age>32</age>
</person>
<person>
<name>Jani</name>
<age>26</age>
</person>
</employees>;
document.write(employees.person.(name == "Tove").age);
This example applies only to Firefox!
XML As a JavaScript object
E4X is an official JavaScript standard, adds direct support for XML.
Using E4X, you can declare Date or by way of Array object variable declaration XML object variable:
var y = new Date()
var z = new Array()
E4X is an ECMAScript (JavaScript) standard
ECMAScript is the official name of JavaScript. ECMA-262 (JavaScript 1.3) was standardized in December 1999.
E4X is a JavaScript extension adds direct support for XML. ECMA-357 (E4X) in June 2004 standardized.
ECMA organization (founded in 1961), is dedicated to information and communication technologies (ICT) and consumer electronics (CE) standardization. ECMA standard established for:
- JavaScript
- C # language
- International character sets
- CD
- Magnetic tape
- data compression
- data communication
- and many more/en.
Do not use E4X
The following example is a cross-browser instance, the instance to load an existing XML document ( "note.xml") into the XML parser, and displays a message Description:
Examples
//code for Internet Explorer
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("note.xml");
displaymessage();
}
// code for Mozilla, Firefox, etc.
else (document.implementation && document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("note.xml");
xmlDoc.onload=displaymessage;
}
function displaymessage()
{
document.write(xmlDoc.getElementsByTagName("body")[0].firstChild.nodeValue);
}
Using E4X
The following example is the same as the example above, but using E4X:
xmlDoc.load("note.xml");
document.write(xmlDoc.body);
More simple, is not it?
Browser Support
Firefox is the only E4X support a better browser.
There is no support E4X areOpera, ChromeorSafari.
So far, there is no indication E4X support inInternet Explorer.
E4X future
E4X is not widely supported. Maybe too practical features it offers, has not been involved in other solutions:
- For the complete XML processing, you also need to learn XML DOM and XPath
- For access XMLHttpRequests, the JSON is the preferred format.
- For simple document processing, JQuery choice easier.