Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Refresher: Object-oriented programming; e.g. JavaScript

December 21, 1998

We're focusing on JavaScript because it is a relatively simple language with deeply traditional roots: anyone familiar with variables, loops, conditions and so forth can quickly adapt to the JavaScript paradigm. Into this mix JavaScript introduces the concept of objects, essentially container constructs which possess any number of associated values known as properties and procedures (a.k.a. "functions") known as methods.

In processing XML data via the Document Object Model we can think of JavaScript as a nearly generic object-oriented language. It should be easy to translate these concepts into the syntax of other languages such as VBScript or even C++, if you are familiar with those rather than JavaScript, per se.

Language aside, the syntax we use to access the XML document is mostly defined by the Document Object Model, itself, rather than the particular programming language. In this sense, an understanding of the DOM will aid in understanding the examples in this article moreso than a mastery of a particular language. To best understand the role of the Document Object Model, and why it's reflection of the XML tree is important, see "The DOM Dissected."

In processing XML we will be concerned mostly with objects representing components of the XML tree. In thinking of the XML data itself we can employ the metaphor of a tree -- an arboreal tree, as opposed to a family tree, which is another metaphor we will encounter later. We can imagine there will be an object analogous to the trunk, an object representing a branch (a.k.a. "node"), and an object representing a leaf. Generally speaking, then, we would use the following generic syntax to access the second leaf of the first branch:

Leaf Object: trunk.branch(0).leaf
valueProperty of Leaf Object: trunk.branch(0).leaf.valueProperty

Thus, we could assign a new value to the above leaf:

trunk.branch(0).leaf.valueProperty="red"

Remember, these are not syntactically accurate examples, simply conceptual sketches to illustrate the object-oriented nature of the XML tree. That said, let's consider just what XML and this "tree" are after all ...


XML via the Document Object Model: A Preliminary Course
XML via the Document Object Model: A Preliminary Course
Refresher: XML


Up to => Home / Authoring / Languages / XML / DOM / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers