开发者

What does it mean by implementing a 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+开发者_StackOverflow社区+ 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜