Yes, it is possible. For example, YourType obj = new YourType(....); XmlSerializer serializer = new XmlSerializer( typeof( YourType ) ); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces( ); namespaces.Add( "", "" );
XmlWriterSettings settings = new XmlWriterSettings( ); settings.Indent = true; settings.OmitXmlDeclaration = true; // substitute the appropriate encoding settings.Encoding = Encoding.ASCII; // using the console here XmlWriter writer = XmlWriter.Create( Console.OpenStandardOutput( ), settings ); serializer.Serialize( writer, obj, namespaces ); Regards, Fernando Tubio ----- Original Message ----- From: "Mike Andrews" <[EMAIL PROTECTED]> To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Sent: Wednesday, March 07, 2007 7:23 PM Subject: [ADVANCED-DOTNET] XmlSerializer question...
Is it possible to create an XmlSerializer that will not create the xmlns attributes and add the <?...?> encoding type to the resultant xml serialized document? Here's what's created: <?xml version="1.0" encoding="utf-16"?> <Root> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="afac03d2-2a9c-42d0-a93c-002850fe71e2" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="31427548-9bfb-493d-9d15-002b35685933" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="92746f5b-5fcd-4821-80b1-002d9669d8c4" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="3dec5a7d-3848-4f7c-bd9c-002df9e70cc6" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="9d560a2a-8899-48f7-8533-00346921bac5" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="e5fea3aa-d674-421d-bb3c-00364086d96a" /> <IDItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" id="ae2ce413-233f-4015-9804-00367feebe5e" /> </Root> and this is what I'd like created instead: <Root> <IDItem id="afac03d2-2a9c-42d0-a93c-002850fe71e2" /> <IDItem id="31427548-9bfb-493d-9d15-002b35685933" /> <IDItem id="92746f5b-5fcd-4821-80b1-002d9669d8c4" /> <IDItem id="3dec5a7d-3848-4f7c-bd9c-002df9e70cc6" /> <IDItem id="9d560a2a-8899-48f7-8533-00346921bac5" /> <IDItem id="e5fea3aa-d674-421d-bb3c-00364086d96a" /> <IDItem id="ae2ce413-233f-4015-9804-00367feebe5e" /> </Root> How can I go about this? Thanks, Mike =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com