Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion serialization: get rid of unwanted xmlns attributes
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christoph Schittko  
View profile  
 More options Jul 25 2002, 12:06 pm
Newsgroups: microsoft.public.dotnet.xml
From: "Christoph Schittko" <ChristophDotNetINVA...@austin.rr.com>
Date: Thu, 25 Jul 2002 11:00:16 -0500
Local: Thurs, Jul 25 2002 12:00 pm
Subject: Re: serialization: get rid of unwanted xmlns attributes
Yeah, I should not post before I had time for my morning coffee ...

You actually have to add an empty namespace declaration to the
XmlSerializerNamespaces object:

XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add( "", "" );
myser.Serialize(writer, myCommand, ns );

will do the trick.

HTH,
--
Christoph Schittko
Software Architect
Mshow - a division of InterCall

"matro" <ma...@usa.net> wrote in message

news:aj60kuge5bdttqln50fpv17etvhjoh53s9@4ax.com...
> On Thu, 25 Jul 2002 09:31:33 -0500, "Christoph Schittko"
> <ChristophDotNetINVA...@austin.rr.com> wrote:

> >To get rid of them you have to pass in an empty new

XmlSerializerNamespaces
> >object to the Serialize() call:

> >serializer.Serialize( writer, yourObject, new

XmlSerializerNamespaces() );

> it doesn't work for me:

> // this is to tell XmlSerializer to use UTF8 encoding
> System.IO.MemoryStream mystr=new System.IO.MemoryStream();
> XmlSerializer myser=new XmlSerializer(typeof(ftService.ftCommand));
> XmlTextWriter writer = new System.Xml.XmlTextWriter(mystr,
> System.Text.Encoding.UTF8);

> // as Christoph said
> myser.Serialize(writer, myCommand, new XmlSerializerNamespaces());

> on the other hand, the initial serialized class looks like the
> following:

> [XmlRootAttribute(ElementName="myCommand")]
> public class ftCommand

> produced XML looks like the following:

> <?xml version="1.0" encoding="utf-8"?><myCommand
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
> ...

> --------

> Francesco "Matro" Martire

> RealPopup, the freeware winpopup replacer
> http://www.realpopup.it

> MaTreo, freeware frontscreen for your Treo
> http://www.realpopup.it/matreo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google