Java: Ways to parse XML in E4X?
Asked Answered
D

4

6

I was wondering if there was a way to parse XML using E4X, or something similar to E4X.

Does such a framework / library exist?

Thanks!

Danutadanya answered 6/1, 2010 at 9:21 Comment(0)
H
3

Java cannot support dynamically defined members, as JavaScript can.

However, with design-time generation, you can get Java whose members reflect the XML. E.g., JAXB

Hauberk answered 6/1, 2010 at 9:25 Comment(0)
H
4

You can use JavaScript engine Rahino with Java which can handle E4X.

  1. http://blogs.oracle.com/sundararajan/entry/desktop_scripting_applications_with_netbeans
  2. http://www.ibm.com/developerworks/library/ws-ajax1/
Heterosis answered 6/1, 2010 at 9:30 Comment(0)
H
3

Java cannot support dynamically defined members, as JavaScript can.

However, with design-time generation, you can get Java whose members reflect the XML. E.g., JAXB

Hauberk answered 6/1, 2010 at 9:25 Comment(0)
U
2

E4X is a language extension, XML is treated like a primitive. E4X is not just for parsing XML, it's using XML as real types.

This can't be simulated or done with a Java 'framework', it would require a language extension for Java.

Unconnected answered 6/1, 2010 at 9:30 Comment(0)
M
0

There is no parsing XML with E4X. It is a specification that makes XML a native data type. Among browsers, only Firefox supports it as of now.

Here's a list of all known implementations of the spec.

A framework can only mimic making XML access easier, but will not fundamentally change the way we use XML. For example, the SimpleXML extension in PHP simplifies things a lot, but under the hood it converts elements to objects using reflection.

So to have something like E4X, it has to be implemented in the language itself and there is no other non-ECMAScript based language that has this as of now.

Malodorous answered 6/1, 2010 at 9:33 Comment(1)
You can parse XML using the XML and XMLList constructors in E4X.Hyphenate

© 2022 - 2024 — McMap. All rights reserved.