Page

18.3.0- XML as Data

  by NT Community Manager.
Last Updated  by Joel Bush.  

PublicCategorized as 18. An Introduction to XML.

Not tagged.
<< 18.2.5- XSLChapter1818.3.1- XML Parsers >>

XML as Data

You may still be thinking that this is a lot to learn, just to have data in a self-describing format that you, as a programmer, can read a bit more clearly. After all, we are still getting similar results to what we can already achieve with HTML. Well, let's stop looking at our XML file as just being used for display on the Web, and let's take a look at the different ways that we might want to use the same data (that is currently used in HTML-based applications).

 

If we are keeping our data separate from the rules in which it can be displayed then we can easily use it in other applications. There are two reasons for this:

 

  • It is not cluttered with style rules
  • The tags are describing their content

 

Taking our book example further, imagine we own a bookstore. As we are interested in computers, our small bookstore does more than display details of books on the Web. We use it for the following:

 

  • A browser-based application for staff to monitor stock
  • To send out to collectors details of our catalog of books in stock

 

Rather than keeping several versions of the same information in different places, we decided to re-use the same data in different ways. In order to do this, we can add a quantity tag to our XML document to show the numbers of each book we have in stock.

 

<books>

<book>

<title>Beginning ASP 3.0</title>

<quantity>20</quantity>

<ISBN>1-861002-11-0</ISBN>

...

 

You may be wondering how a text file like this could actually be used in a practical situation. There are, in fact, a number of ways:

 

  • To expose the elements and their values using the W3C Document Object Model
  • To write a specialized component, that can read XML data, and use it to interact with the application or data store directly
  • Using text string manipulation techniques, which look for matching text in the tags and then retrieves their values
  • Data Binding in IE4/5

 

In the remainder of this chapter we will show you some ways in which you can access and create data in XML documents using the Document Object Model.

<< 18.2.5- XSLChapter1818.3.1- XML Parsers >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |