internet.com

Go to WebDeveloper Home


hm-v6-139x61.gif

Database Journal: The Knowledge Center for Database Professionals

find a web host with:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
jobs

Get FREE Development Info via your Email!

The Webdeveloper channel
FlashKit
GIF.com
HiermenusCentral
webdeveloper Jobs
Java Boutique
JavaScript.com
JavaScript Source
ScriptSearch
StreamingMedia World
WDJ
WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com

internet.com
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

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

internet.commerce
Be a Commerce Partner










 
THE XML FILES
A WebDeveloper.com Feature

What DOMinates XML?

by Nate Zelnick

Understanding the DOM

As you can see, the container model of HTML maps really well to the idea of a document tree that shows the relationship between a branch (called a node) and the trunk it grows out of (called the root).

The tree is just a metaphor that will help you to visualize how a document's elements, attributes and content are related to each other. A DOM implementation may not actually represent its data in this way, but the ways that you can manipulate that structure of a document will work against this kind of visualization, so it's an extremely useful tool. The key to DOM compliance is that the interfaces that a document exposes are the same.

From the Top

The interfaces that the DOM exposes are really a set of methods for dealing with the structure map of a document once it has been parsed.

The parsing process is actually where the structure map is created. In HTML, the structures are understood ahead of time. The document will have a top-level root called HTML, and it will contain a HEAD element that will have some limited set of possible sub-elements with their own limited set of attributes. These elements will contain data that will be children of the elements or their attributes.

But what about XML? Since there are no known elements or attributes of XML ahead of time, the parsing process is really the act of building a structure map of the arbitrary relationship as the document is being read. So a simple XML snippet that describes a customer might look like this in a structure map:

a simple XML structure map for a customer object

How this works is that the root element -- CUSTOMER -- is the top-level object. It contains an element called NAME that has two children: FIRST and LAST. The values of FIRST and LAST are "Joe" and "User". CUSTOMER also contains an element called ADDRESS that also has two children: STREET and CITY. STREET and CITY have values of "123 Main Street" and "Anywhere, USA". So the XML that this structure map describes looks like this:

<CUSTOMER>
 <NAME>
  <FIRST>Joe</FIRST>
  <LAST>User</LAST>
 </NAME>
 <ADDRESS>
  <STREET>123 Main Street</STREET>
  <CITY>Anywhere, USA</CITY>
 </ADDRESS>
</CUSTOMER>

Now the key question is how do you work with this structure? That's the essence of the DOM -- and the subject of the next column.

Fast Jump to Anywhere on WebDeveloper.com®:



internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs


Contact the WebDeveloper.com® staff

Last modified: Friday, 22-Aug-2008 13:46:48 EDT

 

Refresh Daily
Join Editor-in-Chief David Fiedler The Editor With No Time and find truth, justice, and a clue or two.


Browse by Category
[ Site Map ]

ActiveX / VBscript
Animated GIF Archive
Browsers
CGI / Perl
Database Connectivity
E-Commerce
HTML-Advanced: DHTML, CSS
HTML / Site Authoring Tools
Intranet/Groupware
Java
JavaScript
Multimedia: Audio / Video / Streaming Technologies
Opinions
Refresh Daily: Editorial Column
Security
Servers & Server Tools
Site Design / Graphics
Site Management / Marketing / Log File Analysis
VRML / 3D
XML