|Chances are you've heard of XML sometime in the past. For about the past year Microsoft has been saying, "XML-this" and "XML-that." This article is intended for those who are brand-spankin' new to XML and are interested in learning what all the buzz is about!|
Imagine that you ran an eCommerce site that sold widgets. Through your Web site, users could interact with the Widget Database, seeing real-time information on the widget stock, widget availability, and other relevant information. Being an industrious Widget-retailer, you'd like to be able to offer other Web sites to showcase your Widgets. For example, a Widget-information Web site might be interested in listing the widgets that your company currently had in stock.
Providing such a mechanism is not easy. Ideally, you would want to let this Widget Information site be able to access your Widget database directly, grabbing the needed information. However, perhaps you only want to provide a few tidbits of information and keep the rest secret? Offering database access would not be the best solution. Enter a better solution: XML.
XML, which stands for EXtensible Markup Language, is a means by which data can be stored in an easy to read, textual implementation. XML uses a tag-based implementation similar to HTML. However, unlike HTML, there are no predefined XML tags. The creator of an XML file must define his or her own tags, deciding how these tags describe the data they represent.
XML is a bit more stringent about closing tags than HTML. For example, in HTML, a
single tag, like |
In our Widget Web Site example, for those widget-information Web sites we might want to provide the following bits of information on all of our widgets:
- Product Number
This information could be represented by the following XML document:
Note that for each widget in the database one of these entries would exist. The actual
name, cost, product number, and description of each widget would go in the italicized text
areas. Also note the first line,
<?xml version="1.0"?>. This line
identifies that the document is an XML document, specifically a version 1.0 XML document.
Think of XML as a verbose description of a database table. In our above example, the
XML represents a table named
widgets. Each row of the table is represented
widget tag. Each
widget row contains four columns:
So, if our Widget Database contained two widgets, our XML document might look like:
Save this XML file in your Web directory:
In Part 2 we'll look at how to iterate through this XML document via an ASP page. Note that in our Widget Database Example, this XML file could be generated each day or on the fly from the Widget Database Web site.