XML E4X
-- Learn not only technology, but also dreams!- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
XML Tutorial
- XML Tutorial
- XML Introduction
- XML Usage
- XML Tree Structure
- XML Syntax
- XML Elements
- XML Attributes
- XML Validation
- XML Validator
- View XML File
- XML CSS
- XML XSLT
XML JavaScript
Advanced XML
- XML Namespaces
- XML CDATA
- XML Encoding
- XML Server
- XML DOM Advanced
- XML Notes
- XML Technologies
- XML Real Life
- XML Editors
- XML E4X
- XML Summary
- XML Examples
XML - E4X
E4X adds direct support for XML to JavaScript.
E4X Example
var employees=
<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 works only in Firefox!
Try it Β»XML as a JavaScript Object
E4X is an official JavaScript standard that adds direct support for XML.
Using E4X, you can declare XML object variables in the same way as declaring Date or Array object variables:
var x = new XML()
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 an extension to JavaScript that adds direct support for XML. ECMA-357 (E4X) was standardized in June 2004.
The ECMA organization (founded in 1961), specializes in standards for information and communications technology (ICT) and consumer electronics (CE). Standards made by ECMA include:
- JavaScript
- C# language
- International character set
- Optical disc
- Magnetic tape
- Data compression
- Data communication
- etc...
Without E4X
The following example is cross-browser. The example loads an existing XML document ("note.xml") into an XML parser and displays a message:
Example
var xmlDoc;
//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()
{
docu
```
YouTip