aboutsummaryrefslogtreecommitdiff
path: root/files/de/e4x/index.html
blob: ad71bd27789158498333dbfbcb46bf10692258d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: E4X
slug: E4X
tags:
  - E4X
  - JXON
  - JavaScript
  - NeedsEditorialReview
  - NeedsTechnicalReview
  - NeedsTranslation
  - TopicStub
  - XML
translation_of: Archive/Web/E4X
---
<div>
  {{obsolete_header()}}</div>
<div>
   </div>
<div>
  {{ Warning("E4X is obsolete. It has been disabled by default for webpages (content) in Firefox 17, disabled by default for chrome in Firefox 20, and has been removed in Firefox 21. Use DOMParser/DOMSerializer or a non-native JXON algorithm instead.") }}</div>
<p><strong>ECMAScript for XML</strong> (<strong>E4X</strong>) is a programming language extension that adds native XML support to <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a>. It does this by providing access to the XML document in a form that feels natural for ECMAScript programmers. The goal is to provide an alternative, simpler syntax for accessing XML documents than via <a href="/en/DOM" title="en/DOM">DOM</a> interfaces. A valid alternative to E4X is a non-native <a href="/en/JXON" title="en/JXON">JXON algorithm</a>.</p>
<p>E4X is standardized by Ecma International in <a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357 standard</a> (currently in its second edition, December 2005).</p>
<p>E4X is implemented (at least partially) in <a href="/en/SpiderMonkey" title="en/SpiderMonkey">SpiderMonkey</a> (<a href="/en/Gecko" title="en/Gecko">Gecko</a>'s JavaScript engine) and in <a href="/en/Rhino" title="en/Rhino">Rhino</a> (JavaScript engine written in Java).</p>
<p> </p>
<div class="note">
  <strong>Note:</strong> In Gecko 1.8 based browsers such as Firefox 1.5, E4X is already partially enabled for web page authors. To fully enable E4X, the <code>&lt;script&gt;</code> element needs to have the MIME type "text/javascript;e4x=1" (i.e. have an attribute of the form <code>type="text/javascript;e4x=1"</code>). The difference between the two modes is that without the "e4x=1" MIME type, any statement-level XML/HTML comment literals (<code><span class="nowiki">&lt;!--...--&gt;</span></code>) are ignored for backwards compatibility with the comment hiding trick, and CDATA sections (<code>&lt;![CDATA{{ mediawiki.external('...') }}]&gt;</code>) are not parsed as CDATA literals (which leads to a JS syntax error in HTML since HTML's <code>&lt;script&gt;</code> element produces an implicit CDATA section, and therefore cannot contain explicit CDATA sections).
  <p><span class="comment">someone verify the above</span></p>
</div>
<h3 id="Known_bugs_and_limitations" name="Known_bugs_and_limitations">Known bugs and limitations</h3>
<ul>
  <li>It is not currently possible to access a DOM object through E4X ({{ Bug(270553) }})</li>
  <li>E4X doesn't support parsing XML declaration (</li>
  <li>&lt;?xml version=...?&gt;) (see {{ Bug(336551) }}). You may get SyntaxError "xml is a reserved identifier" (despite the XML being in a string).</li>
</ul>
<p>Workaround:</p>
<pre class="brush: js">var response = xmlhttprequest.responseText; // bug 270553
response = response.replace(/^&lt;\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?&gt;/, ""); // bug 336551
var e4x = new XML(response);
</pre>
<h3 id="Resources" name="Resources">Resources</h3>
<ul>
  <li><a href="/en/E4X_Tutorial" title="en/E4X_Tutorial">E4X Tutorial</a> <a class="internal" href="/En/E4X/Processing_XML_with_E4X" title="En/E4X/Processing XML with E4X">Processing XML with E4X</a> on MDC.</li>
  <li><a href="/en/E4X_for_templating" title="En/E4X for templating">E4X for templating</a></li>
  <li>See the list of<a href="/Special:Tags?tag=E4X&amp;language=en" title="Special:Tags?tag=E4X&amp;language=en"> E4X-related pages</a> on MDC:</li>
  <li><a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357 standard</a></li>
  <li><a class="external" href="/presentations/xtech2005/e4x" title="presentations/xtech2005/e4x">Brendan's presentation</a></li>
  <li><a class="external" href="http://web.archive.org/web/20080703182907/http://www.faqts.com/knowledge_base/index.phtml/fid/1762" title="http://web.archive.org/web/20080703182907/http://www.faqts.com/knowledge_base/index.phtml/fid/1762">E4X at faqts.com</a></li>
  <li><a class="external" href="http://rephrase.net/days/07/06/e4x">E4X quick reference at rephrase.net</a></li>
</ul>
<h2 id="See_also">See also</h2>
<ul>
  <li><a class="internal" href="/en/JXON" title="en/JXON">JXON</a></li>
  <li><a class="internal" href="/en/XPath" title="en/XPath">XPath</a></li>
  <li><a class="internal" href="/en/XML" title="en/XML">XML</a></li>
  <li><a class="internal" href="/en/Parsing_and_serializing_XML" title="en/Parsing_and_serializing_XML">Parsing and serializing XML</a></li>
</ul>
<p>{{ languages( { "es": "es/E4X", "fr": "fr/E4X", "it": "it/E4X", "ja": "ja/E4X", "ko": "ko/E4X", "pl": "pl/E4X" } ) }}</p>