Java:在 E4X 中解析 XML 的方法?

发布于 2024-08-16 13:11:03 字数 79 浏览 9 评论 0原文

我想知道是否有一种方法可以使用 E4X 或类似于 E4X 的方法来解析 XML。

这样的框架/库存在吗?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

空宴 2024-08-23 13:11:03

Java 无法像 JavaScript 那样支持动态定义的成员。

然而,通过设计时生成,您可以获得其成员反映 XML 的 Java。例如, JAXB

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

没企图 2024-08-23 13:11:03

E4X 是一种语言扩展,XML 被视为一种原语。 E4X 不仅仅用于解析 XML,它还使用 XML 作为实际类型。

这无法通过 Java“框架”进行模拟或完成,它需要 Java 的语言扩展。

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.

开始看清了 2024-08-23 13:11:03

E4X 无法解析 XML。它是使 XML 成为本机数据类型的规范。目前浏览器中只有 Firefox 支持。

以下是该规范的所有已知实现的列表。

框架只能模仿让 XML 访问变得更容易,但不会从根本上改变我们使用 XML 的方式。例如,PHP 中的 SimpleXML 扩展大大简化了事情,但在幕后它使用反射将元素转换为对象。

因此,要拥有像 E4X 这样的东西,它必须在语言本身中实现,并且目前还没有其他基于非 ECMAScript 的语言具有此功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文