Chapter 11. The XML Document Object Model (DOM)

This chapter explores the XML Document Object Model, often called the XML DOM or simply the DOM, and how it can be manipulated in various ways. The XML DOM is primarily used by programmers as a way to manipulate the content of an XML document. The XML DOM is useful for tasks as diverse as manipulating data from an RSS feed to animating part of an SVG graphic.

Although many XML programmers refer to the XML DOM simply as the DOM, the term DOM can also be used to refer to the HTML Document Object Model, the XML Document Object Model, or both. In this chapter the focus is on the XML DOM.

This chapter covers the following:

  • The purpose of the XML Document Object Model

  • How the DOM specification was developed at the W3C

  • Important XML DOM interfaces and objects, such as the Node and Document interfaces

  • How to add and delete elements and attributes from a DOM and manipulate a DOM tree in other ways

  • How the XML DOM is used "under the covers" in Microsoft InfoPath 2003

Purpose of the XML DOM

The XML DOM provides an interface for programmers to create XML documents; to navigate them; and to add, modify, or delete parts of those XML documents while they are held in memory. There are a number of ways that an in-memory representation can be created:

  • One of the possibilities is to read a file from disk. This is a common technique now when dealing with configuration files; user options held in an XML format are easier to deal with than traditional techniques ...

Get Beginning XML, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.