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

Xml Serialization - Defaulting to XmlIgnore?

I have a pretty complex data structure which I want to serialize to
and from XML, I have tried the .net 2.0 serialization engine and
proved that it will work for my structure.

However by default the serialization engine outputs every property it
comes across and I was wondering if it would be possible to get it to
behave as if everything had the XmlIgnore attribute attached unless
another xml serialization attribute with specified? I.E. output
nothing unless an XmlElement or XmlArray etc attribute was attached.

Thanks

Nick

Mar 5 '07 #1
1 3708
Not without doing it yourself via IXmlSerializable. However, a viable
alternative may be to use the .Net 3.0 "WCF" serialization
[DataContract] and DataContractSerializer; this is "opt in" rather
than "opt out", plus can work on fields or properties equally. The
main difference is replacing [Serializable] with [DataContract], and
adding [DataMember] (with optional name) to the things you want. Oh,
and everything is "element" (i.e. there is no XmlAttribute equivalent
AFAIK); I guess this keeps things simple with nullables etc.

Marc

Mar 5 '07 #2

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

Similar topics

3
by: jamie_m_ | last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error You must implement a default...
6
by: andrewcw | last post by:
I have an object that serializes back and forth. I would like to have some objects not serialize ..and when I read that info back into the class, have this item be null ( or something like it ). ...
2
by: Trevor | last post by:
I have created a class Newsgroup which allows itself to be serialized using Xml serialization attributes. public class Newsgroup { public string Name;
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...
0
by: Tim Cartwright | last post by:
I recently added a new property to a base object that had a property with a protected set. After adding the new propery to the class that inherited from that class, I get the below error. This web...
2
by: Vinayak Kamat | last post by:
Hi, I've got two classes - Entity which will have an array of Child objects in it and Child class. class Entity { public Child Children;
2
by: Vinayak Kamat | last post by:
Hi, I've got two classes - Entity which will have an array of Child objects in it and Child class. class Entity { public Child Children;
3
by: Paulo Morgado [MVP] | last post by:
Hi all ..NET Framework 1.1 I have created several types that are serailized to XML as strings. Someting like this: public struct MyInt32 : IXmlSerializable { int value;
0
by: bharathreddy | last post by:
Before going to that i want to say few thing on serialization : Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

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.