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

serialisation : remove defaut attribute

Hi

Here is another EASY question

When you serialise an object in .NET, serialisation adds defaut attributes
that I dont care

EXEMPLE :
<root_test xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
.......
....
</root_test>

my class is :
Public Class root_test
....
end class

I dont want these parameters...
I just want this : <root_test>....</root_test>

how can i do?????
thanks for this answer

Bye bye

lobrys


Nov 11 '05 #1
2 1739
msnews.microsoft.com wrote:
Here is another EASY question

When you serialise an object in .NET, serialisation adds defaut attributes
that I dont care

EXEMPLE :
<root_test xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
......
...
</root_test>

my class is :
Public Class root_test
...
end class

I dont want these parameters...
I just want this : <root_test>....</root_test>

how can i do?????


Test test = new Test();
XmlSerializer serializer = new XmlSerializer(typeof(Test));
//Here is the trick
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
serializer.Serialize(Console.Out, test, ns);

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
thanks a lot
It's working perfectly

lobrys

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> a écrit dans le message
de news: ud**************@TK2MSFTNGP09.phx.gbl...
msnews.microsoft.com wrote:
Here is another EASY question

When you serialise an object in .NET, serialisation adds defaut attributes that I dont care

EXEMPLE :
<root_test xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
......
...
</root_test>

my class is :
Public Class root_test
...
end class

I dont want these parameters...
I just want this : <root_test>....</root_test>

how can i do?????


Test test = new Test();
XmlSerializer serializer = new XmlSerializer(typeof(Test));
//Here is the trick
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
serializer.Serialize(Console.Out, test, ns);

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

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

Similar topics

1
by: lobrys | last post by:
Hi everybody here is a question I have this class that a want to serialize : Public Class BOO <XmlAttributeAttribute()> Public THING As String <XmlElementAttribute("param")> Public p() As...
1
by: McGiv | last post by:
Hi, I'm trying to serialise some objects and I've can't get the built in serialisation to output exactly what I want. For the moment I'm implementing the IXmlSerializable interface and doing it...
2
by: gary | last post by:
Hi, When I serialise a class to XML which has properties I sometimes have properties that are like this - public double SpeedMPH { get { return (double)Math.Round(windSpeed*2.23693629,2); }...
11
by: Crirus | last post by:
I need to save a quite big structure of classes... but only some members that I need to recondtruct the whole ierarchy. I want to ask how serialisation work... is a efficient way? Or should I deal...
2
by: Crirus | last post by:
Hi all! I have this classes: Public Class Test Public myMember as TestMember Public sub AddMember(ByVal this as TestMember) myMember=this AddHandler myMember.memberEv, AddressOf...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
2
by: ashwinij | last post by:
Hello The steps which i am doing in my program 1) I am having an xml file. 2) I am performing some updations in the file using XQueryUtil class from nux package. 3)After that i am...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
3
by: Rotsey | last post by:
Hi, I am trying to send a object to a webservice and I get an serialisation error on the object saying "object not expected" add "XmlInclude or SoapInclude attribute" I have done this but...
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: 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
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
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...

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.