Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XML Concepts : Page 5

XML is way of marking up data, adding metadata, and separating structure from formatting and style. Web pages are just one of many uses for XML.


advertisement

The DOM
The Document Object Model lets you address, change, and manipulate any individual portion of the Web page.

The phrase "document object model" means that you treat your document as a collection of individual objects, rather than a single solid unit. The W3C DOM is the set of rules for doing this in a standard way in a Web browser, with HTML and XML files.

O Is for Object
In an object-oriented approach, the program or the document is made up of many smaller components called objects. The smaller components can be re-arranged, added to, or removed dynamically.



The idea of objects has become quite popular in both software and documents. The programming language Java and the scripting language JavaScript each has an object-oriented philosophy at its core. The adoption of the standard DOM enables Web pages to share that object approach too.

With an object model, you manage the small pieces, combining them and reusing them as it makes sense—instead of writing one huge applications program or one huge document. You might think of an object approach as being a little like a collection of Lego blocks ... different pieces do different things, but you can combine and recombine them into many different finished projects.

Each object type acts a template. You can use an instance of the same object over and over again. For example, you might have multiple instances of the <canine> element in a document. All the objects share the same name, canine, and work the same way, but each one represents its own set of data and can be addressed individually.

The API
It isn't enough to merely know that an object is an object. You also need to know how to talk to that object and give it commands. That's where the API comes in.

API stands for Application Programming Interface. An API is a set of rules that describes how you can access and manipulate an object. The DOM specification describes the API for HTML and XML documents.

The DOM, by providing a standard API, defines the naming conventions, programming models, and other rules for communicating with an object in an HTML or XML page.

Getting from XML to Objects
In an XML document, each element is actually an object—it has a name and it has attributes that describe it.

The browser, combined with a stylesheet, displays each of the XML elements/objects in a Web page. Because they are objects, you can address and change them individually.

Ah, but just knowing that every piece is an object isn't enough. You need to have a set of rules, an API, to describe how to address those objects when they are placed in a Web page. That's where the DOM comes in.

The DOM does three things—you might think of it as explaining the "who, what, and how" of the Web page.

  1. First, it describes who—which objects are a Web page and how XML objects are represented there?
  2. Second, it defines what—what can these objects do and how do they work with others?
  3. Third, it defines how—how can these objects can be addressed?

The DOM is the translator, the interface that lets all the pieces be represented properly, talk to each other, and communicate with scripts and other action tools.

It is XML that lets you add and identify data, but it is the DOM that lets the script manipulate and display that data on command in the Web browser window.





Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date