Sometimes you need the basic features of a database but don't want the
hassle, and possibly cost, of creating one for a small application. With
the .NET DataSet object and a simple XML document we can emulate the basic
features of a database. In this example, we use an XML document which
stores our product information. We want to look up a product by SKU and
return the price and description to a Web page.
We have three products in our list. The following is a basic XML document,
productlist.xml, containing our data:
<?xml version="1.0" encoding="utf-8" ?>
<ProductList>
<Products>
<SKU>1</SKU>
<Price>100.00</Price>
<Description>Widget #1</Description>
</Products>
<Products>
<SKU>2</SKU>
<Price>10.00</Price>
<Description>Widget #2</Description>
</Products>
<Products>
<SKU>3</SKU>
<Price>30.00</Price>
<Description>Widget #3</Description>
</Products>
</ProductList>
If you think of this document in terms of a database, the data within the
ProductList tags are our database. The data within the Products tags are a
table in the database. SKU, Price, and Descriptions are columns in the Products table. Just like a database, we want to return a row of values,
given a column value.
Comments