From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/archive/web/e4x/index.html | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 files/zh-cn/archive/web/e4x/index.html (limited to 'files/zh-cn/archive/web/e4x') diff --git a/files/zh-cn/archive/web/e4x/index.html b/files/zh-cn/archive/web/e4x/index.html new file mode 100644 index 0000000000..af364a3208 --- /dev/null +++ b/files/zh-cn/archive/web/e4x/index.html @@ -0,0 +1,49 @@ +--- +title: E4X +slug: Archive/Web/E4X +translation_of: Archive/Web/E4X +--- +
+

已废弃
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

+
+  
+
+
+

Warning: E4X已经过时.从Firefox 17开始,E4X在普通网页中被默认禁用,从Firefox 20开始,E4X在浏览器界面中被默认禁用,从Firefox 21开始,E4X被完全删除.使用DOMParser/DOMSerializer或者其他算法来代替.

+
+

ECMAScript for XML (E4X) is a programming language extension that adds native XML support to JavaScript. 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 DOM interfaces. A valid alternative to E4X is a non-native JXON algorithm.

+

E4X is standardized by Ecma International in ECMA-357 standard (currently in its second edition, December 2005).

+

E4X is implemented (at least partially) in SpiderMonkey (Gecko's JavaScript engine) and in Rhino (JavaScript engine written in Java).

+

 

+
+ Note: 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 <script> element needs to have the MIME type "text/javascript;e4x=1" (i.e. have an attribute of the form type="text/javascript;e4x=1"). The difference between the two modes is that without the "e4x=1" MIME type, any statement-level XML/HTML comment literals (<!--...-->) are ignored for backwards compatibility with the comment hiding trick, and CDATA sections (<![CDATA[...]]>) are not parsed as CDATA literals (which leads to a JS syntax error in HTML since HTML's <script> element produces an implicit CDATA section, and therefore cannot contain explicit CDATA sections). +

someone verify the above

+
+

已经的bug和限制

+ +

Workaround:

+
var response = xmlhttprequest.responseText; // bug 270553
+response = response.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
+var e4x = new XML(response);
+
+

资源

+ +

相关链接

+ -- cgit v1.2.3-54-g00ecf