XML: Client Side Processing

While XML is a new product, it works very well with HTML and its related products, such as JavaScript and CSS. In particular, XML can exist in what are called "XML Data Islands" inside HTML. We will introduce XML by starting with examples that emphasize the familiar features of HTML and its brethren while progressively unveiling more features that characterize XML.

Here is a translation in Spanish

Using a Restricted Form of XML

The first set of examples use an XML structure that is very common and widely used, and which map easily into HTML. It is called a "tabular" or rectangular data set. The restrictions are:

Using the Full Unrestricted XML Format

The following examples are fully general and can process any XML data file of any type or complexity. The key ingredient for most of them is a recursive function that "walks" through the tree so it can visit any element node or attribute. The basic recursive program, written in JavaScript, is only about 10 lines long, but may be conceptually difficult to understand simply because it is recursive.

It is important to note that an XML document has a tree structure above and beyond the structure of the data elements themselves. The overall structure of an XML document is something like this:

Document | 
         |-- Processing Instruction 
         |   (e.g., <?xml version="1.0">
         |
         |-- Comment
         |   (e.g., <!-- student DB file -->
         |
         |-- DTD
         |   (e.g., <!DOCTYPE BOOK SYSTEM "books.dtd">
         |
         |-- XML data file itself ...
         |

The actual XML file is but a branch of a tree that usually contains two or three other branches. Let "XMLdoc" be the name of an XML document. Then the root of the actual XML file is given by:

theRoot = XMLdoc.documentElement;