What is DOM Parser?

Asked

Viewed 853 times

3

Reading about regular expression I saw a recurring term, DOM parser, and I had doubts:

  1. What is DOM Parser?
  2. How it works?
  3. Every language has?
  • Great question, always wanted to understand the DOM parse in a more comprehensive way, either for HTML documents or other structure :D ! Here has something to do with.

  • Related http://answall.com/q/40852/101

  • Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?

1 answer

4


Parser

Let’s start with the parser. It is an algorithm that parses a text identifying its parts (tokens) and checking that everything is built according to a specified grammar (probably in BNF). In this specific use it parses an XML document, HTML, etc. and generates a DOM for the application to use.

He goes through the analysis element by element of the text and creates the tree structure. This is explained a little better in a question about functioning of a compiler.

GIFT

The Document Object Model is a large hierarchical object with several elements forming a tree.

It is very common to find DOM associated with XML and similar languages. It is possible that some programming language compilers generate a code DOM for their own use, and even make it available for the application to use at runtime. C# does this, but today has better solutions.

I don’t really like the name because it refers to Parsing of the GIFT and in fact the GIFT is the result that it generates.

Every language has?

Since DOM parser is a software with several specific function components, it is not what languages they will have or not, it is a matter of having a library with that function available for that language. Whether the language handles XML, HTML or something like that is pretty sure that there is something ready in the standard language library. The quality and extent of each may vary.

If the "language" does not always have it is possible to use a third party library.

Do not confuse the DOM with the text itself that generates this model. An HTML is not the DOM, but it is normal to have a direct relationship between them. You can manipulate DOM without manipulating HTML. Or XML, or JSON (less common), SVG, etc. Javascript manipulates DOM, not HTML directly.

The parser delivers a partial or integral tree-shaped structure so that the consumer code can do what it wants. In general, the parser allows you to easily access DOM members and even manipulate them.

Some languages, such as Javascript, by specific characteristic, can have access to the DOM directly, since the DOM ends up being incorporated into the code identifiers.

Is being created a formal specification how it should work.

See more in What is parse, and how the parse of DOM works in HTML5.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.