Multiple controls reading an XML file...efficient or not?

D

darrel

This is a follow up to a semi-regular question I've had off and on.

The main question is how to get one set of variables from an XML file so
that various usercontrols on the page can all use them.

I've been playing with different options...using an interface, a function,
passing variables between controls, etc.

But it just occured to me that perhaps it would make sense just to have each
control that needs a value to read said value. Obviously, having each one
open the XML file to read through it would be a performance hit, but what if
I use a cache object? Cache each XML file and store it in memory until it is
refreshed on the server? Are there drawbacks to this approach?

-Darrel
 
W

Wilco Bauwer

Why not have an object which exposes the data in your XML file?
(assuming its some sort of config file...) You could implement a
singleton, which for example loads the file on demand, and exposes the
data through properties/methods.

Every control can then use that singleton and use the relevant data,
and you only need to load it once, or not at all in case no-one needed
to read from it.
 
D

darrel

Why not have an object which exposes the data in your XML file?
(assuming its some sort of config file...) You could implement a
singleton, which for example loads the file on demand, and exposes the
data through properties/methods.

That might work. Karl actually mentioned that as well. I'll need to google
singleton to see what that's about ;o)

It's not a config file in terms of the site. It's more of a config file for
each 'page' on the site. So, for each page call, it's going to need to get a
unique set of data from the XML file (though the XML file, itself, could be
cached to an extent).

-Darrel
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top