473,387 Members | 1,859 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,387 software developers and data experts.

How to force attributes to be serialized

Hi,

I have used the xsd tool to generate a class from a schema. I then
use the XmlSerializer class to write an object to an XML file. So far
so good.

However attributes that are set to their default values are not
serialized to the XML file. However I would like to force the
serializer to write an attribute to the file, even if it is set to its
default value.

I have experimented with using a custom XmlTextWriter and also by
using XmlAttributeOverrides, but I can't figure out how to achieve
this.

Has anyone done this? Could you post some sample code?

TIA, M.
Nov 12 '05 #1
0 843

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

Similar topics

2
by: Jim Trela | last post by:
How can I find out the names of all the attributes that are intrinsic (pre-defined, or standard) in the .NET framework ? I saw in a presentation that there are supposedly around 178 pre-defined...
2
by: Christopher Ambler | last post by:
I have a class that I deserialize into as such: public class row { public string RecordFound; public string IsExpired; }
1
by: Josh Collins | last post by:
I am trying to serialize something in the format: <groups> <group attr1="" attr2="">VALUE</group> <group attr1="" attr2="">VALUE</group> <group attr1="" attr2="">VALUE</group> </groups> I...
10
by: Marc Selis | last post by:
Hi, I have a class with a static constructor in which the class registers itself as capable of doing something (using a delegate) The problem is that the static constructor is never called, as...
1
by: nospam | last post by:
Hi, I have used the xsd tool to generate a class from a schema. I then use the XmlSerializer class to write an object to an XML file. So far so good. However attributes that are set to...
0
by: Prodip Saha | last post by:
Sorry about the cross-posting but I need to get attention from the ADO.Net and Web Service Gurus! I really need to use the System.Data.OleDb.OleDbParameter Class but I am getting following error...
1
by: guy | last post by:
simple question, are attributes inherited? eg if base class is marked serializable are classes that inherit from it also serializable?
2
by: jamie | last post by:
Perhaps I'm using this wrong. When I use above an attribute I don't want serialized it ignores the attribute. It also ignores some other attributes. Have I done something wrong? Here's...
1
by: =?Utf-8?B?QmVu?= | last post by:
Hi all, I'm a little bit consfused as to when to use each of these options. For example, if i want to decorate a class with some information, I could decalre a const or read only field and have...
0
by: dph5010 | last post by:
I'm trying to make an object that will reflect the response from isbndb.com's API so I can serialize the results into my code. Right now I have code that works, however, the structure isn't quite the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.