17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 16: A Brief XML Primer<br />

Elements can also contain attributes (which we’ll look at shortly) as part of the opening (but not the closing)<br />

tag for the element. Finally, elements can contain other elements, but, if they do, the inner element<br />

must be closed before closing the outer element:<br />

<br />

<br />

<br />

<br />

We will come back to elements shortly when we look at what it means to be well formed.<br />

Nodes<br />

When you map out the hierarchies that naturally form in an XML document, they wind up taking on the<br />

familiar tree model that you see in just about any hierarchical relationship, illustrated in Figure 16-2.<br />

Each intersection point in the tree is referred to as a node.<br />

A secondary Node.<br />

This is the immediate<br />

child of the root node.<br />

There can be zero,<br />

one, or many of these.<br />

Example: Customers<br />

Another Node. A child of<br />

the one above.<br />

Example: Orders<br />

(Customers have<br />

Orders)<br />

Figure 16-2<br />

Another Node. A child of<br />

the one above.<br />

Example: Line Items<br />

(Orders have line items)<br />

Root Node. There<br />

must be one and<br />

only one. It is<br />

often called<br />

“root”, but doesn’t<br />

have to be.<br />

The contents of an XML document can be navigated based on node levels and the values in the attributes<br />

and elements of particular nodes.<br />

The “Root” Node<br />

Perhaps one of the most common points of confusion in XML documents is over what is called the root<br />

node. Every XML document must have exactly one (no more, no less) root node. The root node is an element<br />

that contains any other elements in the document (if there are any). You can think of the root node<br />

as being the unification point that ties all the nodes below it together and gives them structure within<br />

478

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!