JavaScript Editor Free JavaScript Editor     JavaScript Debugger 




Main Page

Previous Page
Next Page

Chapter 6. XML

What can I say about XML that somebody before me hasn't already said? One little Google search is enough to learn that XML whitens whites and brightens brights. In short, name an ill that plagues today's world, and there is probably someone out there who has written an article about it and how XML can fix it.

Alright, I admit it, I'm stretching the truth a little to get my point across. However, it does give something of the feel of the aura that surrounds XMLwell, at least from an outsider's perspective. XML is another one of those "I don't know what it is, but I want it" type of things.

The format of this chapter goes along the following lines:

In its simplest form, XML is nothing more than a text file containing a single well-formed XML document. Come to think of it, the same is pretty much true in its most complex form as well. Looking past all the hype surrounding XML, it is easy to see that XML is merely the text representation of self-describing data in a tree data structure. When you understand this, all that is left are the nitty-gritty little details, as in "What's a tree data structure?" and "How exactly does data describe itself?"

A tree data structure is built of nodes, with each node having only one node connected above it, called a parent node. The sole exception to this rule is the root node, which has no parent node. Nodes can also have other nodes connected below; these are called child nodes. In addition, nodes that are on the same level as the same parent node are called children. Figure 6-1 is a graphical representation of a tree data structure. If you are thinking to yourself, "I've seen this before," you're rightwe also used this example in Chapter 2, "Introducing Ajax."

Figure 6-1. An XML document as a tree


The diagram in Figure 6-1 can also be represented as the XML document shown in Listing 6-1.We used this listing in Chapter 2 as well. But it doesn't hurt to reiterate the points here.

Listing 6-1. An XML Document as Text

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<library>
      <book>
            <series/>
            <title/>
            <author/>
      </book>
      <book>
            <series/>
            <title/>
            <author/>
      </book>
      <book>
            <series/>
            <title/>
            <author/>
      </book>
</library>


Previous Page
Next Page




JavaScript Editor Free JavaScript Editor     JavaScript Debugger


©