Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Document Object Model (DOM)

Access parsed XML documents as trees of node objects

Contributors:  W3C

Summary:  Learn to use the Document Object Model (DOM), a tree API that provides direct access to parts of an XML document. DOM is probably the most popular means of accessing XML documents, offering convenience at the expense of performance.

Date:  25 Apr 2007 (Published 06 Feb 2007)
Level:  Intermediate

Activity:  3363 views
Comments:  

Learn to use the Document Object Model (DOM), a tree API that provides direct access to parts of an XML document. DOM is probably the most popular means of accessing XML documents, offering convenience at the expense of performance.

Document Object Model (DOM) [W3C Recommendation] is an object model for XML documents that you can use to access parts of an XML document directly. In DOM, the document is modeled as a tree, where each component of the XML syntax (such as an element or text content) is represented by a node. DOM is an API that allows you to navigate this tree, moving from parent to child node, to siblings, and more, taking advantage of special properties of certain types of nodes (for instance, elements can have attributes, while text nodes have text data). DOM is designed to be language-neutral. The Object Management Group's (OMG's) CORBA Interface Definition Language (IDL) [ISO International Standard, number 14750] is used to express DOM node and support interfaces.

DOM actually originated as an object model for standardizing scripting operations on HTML and XML objects in Web browsers. In some places, this translates to awkwardness when it is used as a standalone programming API, but this is the usage focused on in this discussion. DOM is evolving through several levels, each of which builds added capabilities upon the prior one. Level 1 covered the basics; Level 2 added namespace support, a UI event model, iterators, and more; and Level 3 adds APIs for loading to and saving from XML document files, integrating XPath, support for validation, and more.

DOM is generally much easier to master than Simple API for XML (SAX) because it doesn't involve callbacks and sophisticated state management. However, DOM implementations generally keep all XML nodes in memory, which can be inefficient for larger documents. Many languages have featured DOM implementations, but because DOM tries to be language-neutral, adherents of particular languages often complain that it is awkward and doesn't take advantage of any language's particular strengths. As a result, many language-specific tree APIs have flourished.


Resources

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=193468
SummaryTitle=Document Object Model (DOM)
publish-date=04252007