When you think ASP, think...
Recent Articles xml
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips
spgif spgif

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
spgif spgif
ASP ASP.NET ASP FAQs Feedback topnav-right
Print this page.
Published: Wednesday, May 10, 2000

Getting Started with XML

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!

- continued -

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 <BR> is acceptable. In XML, however, all tags must have an opening and closing tag, with the data they represent inbetween. XML tags are also case-sensitive.

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:

  • Name
  • Product Number
  • Cost
  • Description

This information could be represented by the following XML document:

<?xml version="1.0"?>
    <name>Widget Name</name>
    <productNumber>Widget Product Number</productNumber>
    <cost>Widget Cost</cost>
    <description>Widget Description</description>

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 by a widget tag. Each widget row contains four columns: name, productNumber, cost, and description. So, if our Widget Database contained two widgets, our XML document might look like:

<?xml version="1.0"?>
    <name>Oblong Widget</name>
    <description>This widget is useful for jobs requiring
                       oblong tools.</description>

    <name>Skinny Widget</name>
    <description>This widget is useful for jobs requiring
                       skinny tools.</description>

Save this XML file in your Web directory: /widget.xml.

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.

  • Read Part 2

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article