We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 34,310 times

Contents

Related Categories

Searching XML using a DataSet & DataView - Introduction

cjscott69

Introduction

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.

Chris Scott is the founder of Host Orlando (www.hostorlando.com) a Web hosting and development company in Orlando, FL specializing in Microsoft technologies. A self-taught programmer, Chris started getting serious about coding three years ago and learned ASP, T-SQL, and JavaScript to supplement his experience with Visual Basic, databases, and shell scripting. He is now focusing on writing Web applications in ASP.NET and is currently working on finishing a transition of his company's customer management system from classic ASP to ASP.NET.

Comments