Dave Smith - 2015-05-21 01:38:53 -
In reply to message 1 from Jim Burns
After giving it some additional thought, I think I have come up with a less abstract example...
Fact: A HTML document is nothing more than a long string of text.
Problem: How to dynamically change values in an HTML document?
Method A: Use regular expressions (regex) to parse the document, locate the matching string and then rewrite the document with the changes.
The challenge to using this method, aside from regular expressions being difficult to manage, is that regular expressions can get greedy if the document is not formatted exactly as expected. One variance, and the replacement either fails or changes the document so drastically that it becomes unusable.
Method B: Document Object Model (DOM), create an object model that represents a document and all its parts.
This allows a very elegant process to make the changes to the part of the object, document in this case, that you are after. If you have ever seen, or used...
this.document.getElementById(id).value = 'New Value'
You have been using the DOM, whether you knew it or not. This object model has changed static web pages to the feature rich, dynamic ones we see today, which would not be possible without it.
Dave