Laying the Ground Work
The ease with which you can display XML data in IE lies in the fact that you can treat the data as either a Document Object Model (DOM) object or an Active Data Objects (ADO) record set. The DOM is an abstraction of how objects contained within an XML document relate to each other. In essence it is a tree whose base is the root node. You're probably already familiar with the DOM in HTML, where the root node is the document object. You reference all other objects/nodes on an HTML page through the root node -- the document object. When IE encounters an XML file, it builds a tree of node objects that you can reference in much the same way as HTML objects -- by using DOM methods to refer to a specific object/node in the tree. After you have a reference to the correct object/node, you can call DOM methods to manipulate it. This month, I'll show you how to update, add and delete records using both ADO and DOM and two different methods to save your data to the client's machine.
Last month I showed you a small phone book application. This month, I'll expand on that by using a much larger phone book
XML document containing data for all the full time faculty at Norwalk Community College. There are over 250 records, which scales the problem up to reasonable real-world levels for an application of this type (view a read-only demo version
). Except for the Save and Delete buttons, the code is very similar to last month's code (see Listing 1
The code in Listing 1
contains a <style> declaration and a hidden form field.
<input type="hidden" value="null" id="savedData"
You'll use those elements during the save process later in this article.