XML Serialization - Remove XML-instance namespace?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Spam Catcher

    #1

    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!

    --
    spamhoneypot@ro gers.com (Do not e-mail)
  • kimiraikkonen

    #2
    Re: XML Serialization - Remove XML-instance namespace?

    On Mar 17, 8:03 am, Spam Catcher <spamhoney...@r ogers.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...@ro gers.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.dt d">

    Just an idea.

    Comment

    • Spam Catcher

      #3
      RE: XML Serialization - Remove XML-instance namespace?

      =?Utf-8?B?SmFybGF4bGU =?= <Jarlaxle@discu ssions.microsof t.comwrote in
      news:72620359-8D69-4D2D-B3F2-93485FBAD4AE@mi crosoft.com:
      XmlTextWriter formatter = new XmlTextWriter(s tringWriter);
      XmlSerializerNa mespaces namespaceSerial izer= null;
      >
      if (!bNamespaces)
      {
      namespaceSerial izer = new XmlSerializerNa mespaces();
      namespaceSerial izer.Add("", "");
      }
      XmlSerializer xmlSerializer= new XmlSerializer(o bj.GetType());
      xmlSerializer.S erialize(format ter, obj, namespaceSerial izer);
      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!

      --
      spamhoneypot@ro gers.com (Do not e-mail)

      Comment

      Working...