473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Serialization and text formatting

Up front, i'm not very good with serialization and i'm not quite sure what
capabilities it has.

I have an app that outputs a text file with this format:

<root>
\t <node1>
\t\t text...
\t <\node1>
\t <node2>
\t\t text...
\t <\node2>
</root>

The tags and text for node1 and 2 are generated in the classes Node1 and 2.
The Root class adds root tags and tab formatting to the inner Nodes and
text. The Node classes add an additional layer of tab formatting to their
respective content.

Does it make sense to try and make the outer and inner classes serializable?
If so, how would i add the padding in the parent class?
Nov 16 '05 #1
1 2093
I'm not sure what you mean. If node1, node2 and root are class and root
has node1 and node2 properties then you can serialize then as you have
described and the framework classes will format them nicely for you.

something like this :

XmlSerializer serializer = new XmlSerializer(typeof(Root));
TextWriter tw = new StreamWriter(filename);
serializer.Serialize(tw, _root);
tw.Close();

Add the [Serializable()] attribute to your classes

HTH.
"Chuck Bowling" <ch**********@sbcglobal-NO-SPAM.net> wrote in
news:#Z**************@TK2MSFTNGP09.phx.gbl:
Up front, i'm not very good with serialization and i'm not quite sure
what capabilities it has.

I have an app that outputs a text file with this format:

<root>
\t <node1>
\t\t text...
\t <\node1>
\t <node2>
\t\t text...
\t <\node2>
</root>

The tags and text for node1 and 2 are generated in the classes Node1
and 2. The Root class adds root tags and tab formatting to the inner
Nodes and text. The Node classes add an additional layer of tab
formatting to their respective content.

Does it make sense to try and make the outer and inner classes
serializable? If so, how would i add the padding in the parent class?


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Hollywood | last post by:
First, is it possible to use XmlArrayItem to declare two data types, DT1 and DT2 where DT2 is a derived class, in an ArrayList as the same ElementName? The following throws a...
3
by: Noël Danjou | last post by:
VS.NET 2003, C# and .NET Framework 1.1. Hello, I am trying to serialize a small sample class using the XmlSerializer class. ** Here is the code: DerivedClass myClass = new DerivedClass(5,...
7
by: Dave | last post by:
Hi all, I know there is a lot of information on here about Serialization, but I can't find what I need so I thought i would ask. I am trying to serialize and deserialize a set of data. ...
1
by: Dave | last post by:
I'm having trouble dynamically deserializing information. The following code is what I have. It serialises fine, the Dave element is serialized as the Name of the element, not its value. On...
0
by: davesauny | last post by:
Hi guys, I'm having trouble with serialization especially of array elements! What I have is an array of clsUsers which have various properties as shown in the code below The XML I want to...
1
by: Paul Hale | last post by:
Im currently developing an API using a vb.net web service. Im very nearly there as regard to functionality but would like to add a feature so that users can see exactly what xml is being generated...
6
by: John Glover | last post by:
I'm having a very strange problem with XML serialization. I'm writing web services which pass instances of various classes back and forth as parameters and return values of web methods. The...
4
by: Alex D. | last post by:
does any body knows the pros and cons between binary and xml serialization if use it to persist objects in a database and which one is the best option? Tnx.
4
by: Val | last post by:
I have a complex object that I need to serialize. Rather than rely on a standard routine, which is called during the serialization/deserialization, I would like to be able to use my own functions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.