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

XmlSerializer question...

Hi All,

When using XmlSerializer is there anyway of keeping "xsi", "xsd" namespaces
and PI
appearing in the xml file ?

<?xml version="1.0"?>
<myClass xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Test"
Visible="false" />

Just want a simple clean one like the following...
<ColumnInfo Name="Test" Visible="false" />

Thanks,
Nov 12 '05 #1
4 1962
Maersa wrote:
When using XmlSerializer is there anyway of keeping "xsi", "xsd" namespaces
and PI
appearing in the xml file ?


That's a FAQ.

XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
serializer.Serialize(writer, object, ns);

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2
XmlSerializer s1 = new XmlSerializer(typeof(MyType));
MyType t1= new MyType();

// use this to "suppress" the default xsd and xsd-instance namespaces
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add( "", "" );

s1.Serialize(System.Console.Out, t1, ns);
"Maersa" <ma*****@hotmail.com> wrote in message
news:uR**************@TK2MSFTNGP09.phx.gbl...
Hi All,

When using XmlSerializer is there anyway of keeping "xsi", "xsd" namespaces and PI
appearing in the xml file ?

<?xml version="1.0"?>
<myClass xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Test"
Visible="false" />

Just want a simple clean one like the following...
<ColumnInfo Name="Test" Visible="false" />

Thanks,

Nov 12 '05 #3
Maersa,

This question is coming up quite frequently. Check the archives [0].

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

http://groups.google.com/groups?thre...%40tkmsftngp10

"Maersa" <ma*****@hotmail.com> wrote in message
news:uR**************@TK2MSFTNGP09.phx.gbl...
Hi All,

When using XmlSerializer is there anyway of keeping "xsi", "xsd" namespaces and PI
appearing in the xml file ?

<?xml version="1.0"?>
<myClass xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Test"
Visible="false" />

Just want a simple clean one like the following...
<ColumnInfo Name="Test" Visible="false" />

Thanks,

Nov 12 '05 #4
we need a FAQ document.

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:OW**************@TK2MSFTNGP09.phx.gbl...
Maersa,

This question is coming up quite frequently. Check the archives [0].

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

Nov 12 '05 #5

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

Similar topics

0
by: Kevin Conroy | last post by:
I'm making a 6-tiered application that is using Xml to tie the various layers together in a very clean manner. I'm also trying to do this on the 1.1 Framework although I'm willing to switch to the...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
2
by: magister | last post by:
Hello I got this working but it is not how I really want it, basically I have an xml file which has a root of <test> and can be filled with 3 different types of <question> elements with different...
3
by: Cindy Liu | last post by:
Hi, I use XmlSerializer to serialize xml string. It escapes xml special charaters, like < and > to < and >. How can I stop XmlSerializer to escape these charaters? Thanks in advance!!! Cindy
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
4
by: BuddyWork | last post by:
Hello, When running the following line of code XmlSerializer serializer = new XmlSerializer(typeof (MyXmlTestClass)); I get the following exception message. An unhandled exception of
1
by: Yewen Tang | last post by:
I have a schema file datamodel.xsd, element "properties" is declared as a type of "baseProperty". The schema file also defines "derivedProperty" is a derived type of "baseProperty". <?xml...
0
by: PSingh | last post by:
Hi, I know this is a frequently asked question but have tried several combinations and cant seem to figure this out. I am serializing my object as follows: XmlSerializer serializer = new...
6
by: Andrew | last post by:
I am using an XmlSerializer to save some settings and I have discovered that when a string is saved containing a cr+nl it is replaced with just a newline when loading back in. I am no expert with...
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: 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
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
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.