all groups > dotnet xml > may 2006 >
You're in the

dotnet xml

group:

overwrite a serialized object


overwrite a serialized object Lee Crabtree
5/8/2006 11:07:20 AM
dotnet xml:
I'm serializing an object into a file in XML. After the object is
serialized, some other relevant data is written into the file. The rest
of the data winds up being very large most of the time.

Is there a way to re-serialize the object over itself? Here's a quick
example:

Say I have this:

<?xml version="1.0" encoding="utf-8"?>

<fileroot>

<SerializedObject>
<intParam>6</intParam>
<doubleParam>4.68</doubleParam>
</SerializedObject>

<otherData>blarg</otherData>

</fileroot>

Is it possible to replace the SerializedObject without disrupting the
rest of the data?

Thanks,

RE: overwrite a serialized object Chakravarthy
5/9/2006 12:46:01 AM
Correct me ... if i'm not mistaken, all you want is, remove the
SerializedObject node and append new node in that place?

Yes it is possible... ping here, for more...
--
Every thing is perfect, as long as you share!!!


[quoted text, click to view]
Re: overwrite a serialized object Lee Crabtree
5/9/2006 10:14:58 AM
That's right. What I've tried has worked as long as what is being
appended is the same size as what's being overwritten. Otherwise,
excess garbage sits on the end, or I overwrite data beyond the
serialized object.

Lee

[quoted text, click to view]
Re: overwrite a serialized object Chakravarthy
5/9/2006 10:22:02 PM
What is the mechanism did you use to append the data to XML elements?
Secondly, there is no restriction about the size that matters while appending
or deleting...

Post the code, to help you better
--
Every thing is perfect, as long as you share!!!


[quoted text, click to view]
Re: overwrite a serialized object Lee Crabtree
5/10/2006 10:29:05 AM
Well, I couldn't use the XmlDocument class, as it is a full cache tree
of the file. A file of several hundred megs is prohibitively large and
slow, and I can't afford that kind of pain. So I was using
XmlTextReaders and XmlTextWriters to change the data and write it back.
But, as I said, data was either overwritten or underwritten.

Lee

[quoted text, click to view]
Re: overwrite a serialized object Chakravarthy
5/10/2006 11:38:01 PM
Ken Getz, is another MVP and one of his webcast will help you in detail about
how to handle the nodes insertion and deletion. You can reach his website for
this, i would suggest you to spend some time to listen what he says and go
ahead with your work.

At this link, http://www.mcwtech.com/2004/webcasts/ you can find all his
contributions towards the dev community, among which you also see the XML DOM
topic with the title, "Using the XML DOM in .NET Applications"

Dont think that instead of listening to him, you can do R&D over internet
.... this will be definitly helpful to you...

--
Every thing is perfect, as long as you share!!!


[quoted text, click to view]
AddThis Social Bookmark Button