473,385 Members | 2,274 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.

XML Serialization - Remove XML-instance namespace?

Hello Everyone,

When I'm serializing my objects to XML, .NET seems to put the following
namespace into certain elements:

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

Does anyone know what its for? Is there a way to prevent .NET from adding
this information?

Thanks!

--
sp**********@rogers.com (Do not e-mail)
Mar 17 '08 #1
2 1155
On Mar 17, 8:03 am, Spam Catcher <spamhoney...@rogers.comwrote:
Hello Everyone,

When I'm serializing my objects to XML, .NET seems to put the following
namespace into certain elements:

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

Does anyone know what its for? Is there a way to prevent .NET from adding
this information?

Thanks!

--
spamhoney...@rogers.com (Do not e-mail)
Withoug being sure, my guess is that the XML will take some standard
references from W3 just like being in HTML in that code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Just an idea.
Mar 17 '08 #2
=?Utf-8?B?SmFybGF4bGU=?= <Ja******@discussions.microsoft.comwrote in
news:72**********************************@microsof t.com:
XmlTextWriter formatter = new XmlTextWriter(stringWriter);
XmlSerializerNamespaces namespaceSerializer= null;

if (!bNamespaces)
{
namespaceSerializer = new XmlSerializerNamespaces();
namespaceSerializer.Add("", "");
}
XmlSerializer xmlSerializer= new XmlSerializer(obj.GetType());
xmlSerializer.Serialize(formatter, obj, namespaceSerializer);
formatter.Close();
I tried inheriting XMLSerializer and overriding the "Serialize"
procedure... but it doesn't seem to execute. Do you if there is anything
special to do when overriding XMLserializer?

Thanks!

--
sp**********@rogers.com (Do not e-mail)
Mar 18 '08 #3

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

Similar topics

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;
1
by: Miguel Dias Moura | last post by:
Hello, Could someone tell me what are the main differences between using Binary or XML serialization? I am saving complex types in my profile but I am not sure which serialization to use. ...
4
by: jw56578 | last post by:
how would i structure a C# class to properly serialize into the following XML Schema <root> <MainItem> <SubItem/> <SubItem/> </MainItem> </root>
5
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, We have an app that uses XML serialization throughout. As everyone probably knows, using XML serialization is not always a good idea in a big project...
5
by: RobinS | last post by:
I want to serialize a class that I am using to retain some information the user types into a screen. I have 3 questions. 1) I serialized it as XML to start with. This works, but how do I...
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
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
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?
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
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.