Best way to use XML data source and reuse code?

A

Ariana

I have the following situation for an ASP.NET 2.0 web site:

- Data is in one XML file
- I want to transform the data using an XSLT file before using it
- The data is hierarchical
- The data will change only occasionally but is quite large and needs
to be up to date when it does change
- The data will be used to display information in a standard format on
every page, but will be filtered on different pages

Basically, what I'm looking for are suggestions and discussions on the
best way to:

- Cache the data but update it when necessary
- Create reusable code to display the data
- Filter the data when necessary
- Sort the data without reapplying an XSL template

So far, I've got a DataList control bound to an XmlDataSource which
does everything except sorting, but I can envisage solutions involving
DataSets, user controls etc, and I wanted to see what the best options
were in everyone's opinion...

Thanks!
 
K

Kevin Spencer

I would create a class that mirrors the structure of the XML file, and can
de-serialize the XML file into an instance of the class, and serialize the
class to an XML file in the same format as the original. Then you load it
one time from the file system, work with the class in memory, and only save
it back when you need to.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
A

Ariana

Kevin said:
I would create a class that mirrors the structure of the XML file,
and can de-serialize the XML file into an instance of the class, and

Thanks. I had a sneaking suspicion that that might be the way to go - it
would also be more flexible if I ever get the data in something else than
XML. It just means more work right now... :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top