Several design questions

  • Thread starter Thread starter Ayende Rahien
  • Start date Start date
A

Ayende Rahien

I'm storing my data inside an XML file, the data is divided into several
niches.
I expect two things to happen during normal use of the application:
A> Number of niches to grow.
B> Amount of information in niche would grow.
This would result in one big file, it's not too much trouble to change it
now to mutliply files, the question is what would be better from design and
performance perspective?

Several other questions:
I'm reading data from XML in two ways right now:
A> By loading the XML to an XMLDocument and then doing a seria of XPath
queries.
B> By iterating over all the nodes using foreach and a giant switch
statement.
What is better (design & perfomance) would it be better to use XMLReader and
the giant switch? Or is there another way?

Another thing, saving the data:
Currently I'm doing this via XMLDocument.Save() after updating all the
fields that have been changed.
Would XMLWriter be better?

I'm going to write an image to the file, is the only way to retrieve it is
via XMLReader.GetBinary() or does XMLDocument has that option too?

Thanks in advance,
Ayende Rahien
 
Ayende Rahien said:
I'm storing my data inside an XML file, the data is divided into several
niches.
I expect two things to happen during normal use of the application:
A> Number of niches to grow.
B> Amount of information in niche would grow.
This would result in one big file, it's not too much trouble to change it
now to mutliply files, the question is what would be better from design and
performance perspective?

Several other questions:
I'm reading data from XML in two ways right now:
A> By loading the XML to an XMLDocument and then doing a seria of XPath
queries.
B> By iterating over all the nodes using foreach and a giant switch
statement.
What is better (design & perfomance) would it be better to use XMLReader and
the giant switch? Or is there another way?

Another thing, saving the data:
Currently I'm doing this via XMLDocument.Save() after updating all the
fields that have been changed.
Would XMLWriter be better?

I'm going to write an image to the file, is the only way to retrieve it is
via XMLReader.GetBinary() or does XMLDocument has that option too?

One more thing, I've an information storage class (IE, a class that does
nothing except store information) that I currently load/save from XML.
Would it be wiser to just save the node containing the data about this class
and return it via XPath queries using propeties?
 
It depends what you want to do with the data. Do you
1. Want an in memory representation of all the xml nodes
OR
2. Do you want to just run thru all the nodes once
without storing anything in memory.

XMLDocument loads the complete document in memory as a
tree structure. So this is better for option 1.

With XMLReader & XmlWriter you are not storing anything
in memory, so this is better for option 2.

For option 1, I would also recomment looking at the
loading the data as a ADO.NET DataSet. The DataSet loads
the XML data in its own binary format and therefore I
believe quering & modifying data would be much faster.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconloadingdatasetfromxml.asp

Vikas Manocha
www.vikasman.com
 
Back
Top