[dba-VB] XML and class serialization

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Sun Sep 20 09:39:32 CDT 2009


Hi John,

What "HUGE overhead" do you mean?
Do you mean XML file size?
BTW, you can try to serialize collections' and objects' into binary 

http://www.java2s.com/Code/CSharp/File-Stream/CSerialization.htm

and JSON 

http://pietschsoft.com/post/2008/02/NET-35-JSON-Serialization-using-the-Data
ContractJsonSerializer.aspx

files/strings.

As for XML processing in memory - it is very effective and is
"out-of-the-.NET-box" - I suppose that in memory XML files are stored very
"tightly packed" without any overheads - they (I guess) are more like
hierarchical in memory databases (remember IMS?) than plain files IOW in
memory XML processing using XPATH etc. could(/should?) work quicker than SQL
processing of loaded in memory relational databases...

Thank you.

--
Shamil

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Sunday, September 20, 2009 6:06 AM
To: Access Developers discussion and problem solving; VBA
Subject: [dba-VB] XML and class serialization

In another look at the uses of XML, many moons ago when I was trying to
learn VB.Net, I wrote some 
stuff which used classes to store data.  I am going to generalize here since
I only vaguely remember 
what I did.  Please pardon me if I use terms wrongly, and jump right in with
the correct terminology.

IIRC...

A class can inherit the serializer interface which allows the controlling
class to call a method of 
the data class and tell it to "serialize" itself to an XML file or to load
itself from an XML file 
(actually a stream IIRC).  This was really quite cool stuff in a way since
you could enter data into 
a form, store the data into a class instance, enter more data into a form,
store that in another 
class instance, storing all of these instances in a collection.  Then you
could write the whole 
thing out to a stream which ended up being an xml file on disk.  Load the
whole thing back out of 
the file on disk into the data class instances and store them in the
collection.

Obviously you could likewise load classes from data in a table or anywhere
else you might get source 
data.

This ended up being a quick and dirty and EASY to implement (once you
learned how to do it of 
course) way of storing and loading data.  No database file required, just
XML files on disk.  Now I 
do not want to get back into the efficiency thing, I freely admit that XML
has a HUGE overhead.

I am taking a course in c#.  One assignment is to create a "grading program"
where a form is used to 
enter grades.  Three types of grades, each with a different weight.  Enter a
bunch of grades and 
calculate a final grade.

To make it interesting and learn how to use classes and collections in C# I
am taking the grades and 
storing them in class instances, storing the instances in a collection.
This allows me to move back 
and forth in the entered grades, make corrections if there is a data entry
error etc.  A bit beyond 
the scope of the assignment but more interesting.

So... if I make the classes serializable, I can then store them out to an
XML file and read them 
back again.

It seems the instructor knows barely more than I do about C# so it should
float her boat.

-- 
John W. Colby
www.ColbyConsulting.com
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com


 

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4441 (20090919) __________

The message was checked by ESET NOD32 Antivirus.

http://www.esetnod32.ru
 




More information about the dba-VB mailing list