实现 DOM 意味着什么

发布于 2024-12-01 04:52:27 字数 204 浏览 1 评论 0原文

我看到“实现 DOM”这句话,想问一下这到底是什么意思?

我认为大多数浏览器中 DOM 都是由 C++ 实现的。而DOM API是通过Javascript暴露给用户的?那么使用 PHP/Java 甚至像 jsdom 那样的 Javascript 来实现 DOM 意味着什么呢?

一个更具体的问题是为什么人们想要使用其他语言重新实现 DOM?

谢谢

I came across this phrase "implementing a DOM" and want to ask what does that mean exactly?

I think DOM is implemented by C++ in most browser. and DOM API is exposed to users through Javascript? So what does it mean to implement the DOM using PHP/Java or even Javascript such as jsdom did.

A more specific question is why would people want to re-implement DOM using other languages?

Thanks

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

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

发布评论

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

评论(1

星光不落少年眉 2024-12-08 04:52:27

我认为大多数浏览器中 DOM 都是由 C++ 实现的。而DOM API是通过Javascript暴露给用户的?

或许。我确定 Internet Explorer 使用 MSXML用于操作 DOM。由于它是一组 COM 组件,因此可用于多种不同的语言。该实现很可能是用 C++ 编写的,但从应用程序的角度来看,这并不重要。

那么使用 PHP/Java 甚至像 jsdom 这样的 Javascript 来实现 DOM 意味着什么?

DOM 是推荐的用于处理 XML 文档的应用程序编程接口。实现 DOM 基本上意味着实现符合此接口的 XML 解析器和树结构库。

这是API的一个约定。它让熟悉 DOM 操作的人在使用新库时有“宾至如归”的感觉。当您使用另一种语言(例如服务器端 Java、Python、Ruby 和客户端 JavaScript)时,通常会发生这种情况,但如果您开始使用同一语言的另一个项目,但该项目使用不同的库,则可能会发生这种情况。

一个更具体的问题是为什么人们想要使用其他语言重新实现 DOM?

因为并不是每个人都同意使用哪种编程语言。如果您真的喜欢 Haskell 并且您选择以 XML 格式操作文档(即持久数据,或用于与其他理解 XML 的软件(例如 Web scaping)进行通信,那么您需要在 Haskell 中操作 XML 文档。然后,您需要一个 Haskell 中的 XML 库。

请注意,即使人们同意单一编程语言,由于人们在政治方面存在分歧,例如软件许可问题和编程风格、所需的功能等,可能仍然会有许多不同的库。

I think DOM is implemented by C++ in most browser. and DOM API is exposed to users through Javascript?

Maybe. I'm sure that Internet Explorer uses MSXML for manipulating the DOM. As it's a set of COM components, it is available for use in many different languages. It's likely that this implementation is written in C++, but it doesn't really matter from the application's point of view.

So what does it mean to implement the DOM using PHP/Java or even Javascript such as jsdom did.

DOM is the recommended application programming interface for working with XML documents. Implementing a DOM basically means implementing an XML parser and tree structure library that complies to this interface.

This is API is a convention. It allows people familiar with DOM manipulation to "feel at home" when they use a new library. This usually happens when you use another language (e.g. server-side Java, Python, Ruby and client-side JavaScript), but may happen if you start using another project in the same language, but that project uses a different library.

A more specific question is why would people want to re-implement DOM using other languages?

Because not everyone agrees on which programming language to use. If you really like Haskell and you choose to manipulate documents in XML format (i.e. persisting data, or for communication with other software that understands XML -- web scaping, for instance), then you'll need to manipulate XML documents in Haskell. Then, you'll need a library for XML in Haskell.

Note that, even if people agreed on a single programming language, there would probably still be many different libraries as people disagree on political grounds, such as software licensing issues and programming style, desired features, etc.

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