What Is an XML Document?


Before we go any further, let’s take a look at exactly what an XML document is. These details are important to understand once we start getting XML from SQL Server 2005. Though SQL does the formatting for us, we need to understand what we are getting out of the server before we can start manipulating it.

An XML document is made up of tags and elements. You might say that HTML does the same thing, and you would be correct. The difference is XML is data; HTML is how to format the data. HTML and XML work together to make our data look good. In HTML, we are given a specific number of tags we can use, which will instruct the browser how to format the output. In XML, we can generate our own tags that actually define the meaning of the data we are sending. So I may have a <company> tag that contains my company name. If I were to do this in HTML, the browser would ignore the invalid tags and continue processing.

Here, we can see how HTML describes how to display data:

 <Table>  <TR>   <TD>Company</TD><TD>Microsof t</TD>    </TR>      <TR>          <TD>Address</TD><TD>One Microsoft Way</TD>      </TR>       <TR>       <TD>City</TD><TD>Redmond</TD>       </TR>       <TR>           <TD>State</TD><TD>Washington</TD>       </TR> </Table>

Now here is XML, defining the actual meaning of data:

 <Customer>     <businessdetails>       <companyname>Microsoft</companyname>        <address>One Microsoft Way</address>         <city>Redmond</city>         <state>Washington</state>        </businessdetails> </Customer>

So let’s go over the contents of an XML document. Understanding the contents will allow you to write well-formed XML documents. Being well-formed is very important. Remember, as with anything else, garbage in, garbage out. If we do not format our XML correctly, our processing application or browser will not know what to do with it.




Microsoft SQL Server 2005. The Complete Reference
Microsoft SQL Server 2005: The Complete Reference: Full Coverage of all New and Improved Features
ISBN: 0072261528
EAN: 2147483647
Year: 2006
Pages: 239

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net