Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E4X browser support

Tags:

javascript

e4x

I'm trying to figure this out, but there's not much information. Which browsers support E4X, and why isn't it more widely adopted?

like image 419
ChrisOh Avatar asked Feb 13 '10 08:02

ChrisOh


3 Answers

Which browsers support E4X

Firefox and others based on the Mozilla codebase.

why isn't it more widely adopted?

Because it offers little practical functionality not already covered by existing standards such as DOM.

OK, it's simpler to use than DOM, but as the price for that you don't get access to all the features of XML, and the thoroughly idiotic, needless XML literal/template syntax is a security disaster, making it so authors of even completely static htaccess-protected documents have to worry about working around the feature.

As a simpler method for accessing the results of an XMLHttpRequest, JSON totally won. For full-on XML processing, you still need DOM. For easier document handling, there are selectors, XPath and JS libraries that can do it without having to introduce weird new language syntax.

That doesn't leave much of a niche for E4X. TBH I wish it would die. (ETA: it has now pretty much done so.)

like image 172
bobince Avatar answered Nov 15 '22 23:11

bobince


Firefox dropped E4X support in version 16:

E4X is deprecated. It will be disabled by default for content in Firefox 16, disabled by default for chrome in Firefox 17, and removed in Firefox 18. Use DOMParser/DOMSerializer or a non-native JXON algorithm instead.

like image 20
Darth Egregious Avatar answered Nov 15 '22 21:11

Darth Egregious


According to w3schools, "Firefox is currently the only browser with relatively good support for E4X."

You could try XPath instead. Although XPath isn't cross-browser there are several Javascript solutions for it like this jQuery plugin.

EDIT

You could actually use jQuery without a plugin for this:

$('<xml><some><code>code</code><tag>text</tag></xml></xml>').find('some > code').text()
like image 3
Harmen Avatar answered Nov 15 '22 21:11

Harmen