Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Processing XML 1

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi All

A general question really not so much a problem. Has anyone worked with the xml namespaces in asp.net and if so how did you find it.

I've been working on a project, one of the requirements of which is to store prefernces against a user such as most commonly selected items from lists. As I hadnt used XML with .net yet I thought i'd use this as an opportunity to have a play.

Great the XML support is pretty good and there is a lot of useful features tucked away in the XPATH namespace. Problem is performance. Even very simple operations processing a basic xml file such as select a group of nodes based on an xpath expression and writing out their text to the screen takes several seconds to complete.

I can't afford this sort of degradation in performance to my app when the same functionality from a database can be resolved in a fraction of a second.

Anyone used XML successfully, encountered similar performance limitations, got any tips for making XML usable within .net as at the moment it seems to slow to be of any real value.

All thoughts appreciated. Have a good weekend ;-)

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
How many records do you anticipate to have in your XML?

For example, you said you were storing user preferences. How many user preferences do you anticipate for a user?

Where I'm going with this is, XPath queries can become very slow once you're above 2000 records (or so) in a XML doc. XML is not a substitute for a database.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
If you're looking for performance, the best bet is to use an XmlTextReader, which delivers forward-only access to data, which is like going through a recordset with a database connection.

You can find most the XML classes used by the .NET Framework under the System.Xml namespace.
 
Chip: At the moment I only have a handful of records in the XML file, I guess we could have as many as 1500 users with preferences eventually. Ultimately this functionality has always been destined for a database. We're at the end of the first in a series of internal apps which are all going to draw on the same centralised store for user preferences. The idea being they are a suite of applications so some preferences will carry over between them. I guess really i was just using this as an opportunity to use XML with .NET for a bit of fun.

Jason: My first hit was with the XmlTextReader but the forward only nature means a lot of logic in my C# to locate the required record etc. The XPATH namespace allows for some great searching such as the MoveToId and Select methods of the XmlNavigator and XmlNodeIterator objects.

All in all I was surprised at how slow these have been in use with a VERY basic XML file - no more than four levels of nesting, all data in tags barring one ID attribute for users and a full DTD.

Thanks for the feedback. I'm goign to carry on playing with this for a while as converting to a database will be simple enough and for once I've got a little breathing space. Any other thoughts always appreciated.

Rob




------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Rob
Not knowing the specifics of this, I have only some general suggestions.
1. I know it's not in line with your centralised idea, but what about cookies?
2. Reading the XML file from disc every time may be causing your performance to degrade. It may be appropriate to cache this in memory in the same way ASP.net caches the web.config file

Check out


Good luck.

Mark [openup]
 
Thanks Mark, I'd not thought at all towards using caching in thsi manner. As we want some preferences to be common across a number of applications then cookies also is no good for us. Its going to have to go into a database eventually i think but as i've got a bit of time at the moment - probably not anymore now i've said it!! - i'm going to continue my playing with the XML for the moment.

:)

Thanks

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top