Question:
I use a serializable dictionary class, found at
http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx
, to serialize a dictionary.
It works fine with the example class below.
<System.Xml.Serialization.XmlRoot("ccl")> _
Public Class ccl
<System.Xml.Serialization.XmlElement("name")> _
Public xx As String = ""
<System.Xml.Serialization.XmlElement("date")> _
Public yy As String = ""
'<System.Xml.Serialization.XmlElement("adict")> _
'Public ww As New SerializableDictionary(Of String, String)
End Class
But it adds a bloody xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance AND xmlns:xsd="http://www.w3.org/2001/XMLSchema? to the tag
Now I fixed it by changing the dictionary class to
Dim ns As System.Xml.Serialization.XmlSerializerNamespaces = New System.Xml.Serialization.XmlSerializerNamespaces()
'Add an empty namespace and empty value
ns.Add("", "")
If True Then
valueSerializer.Serialize(writer, value, ns)
Else
valueSerializer.Serialize(writer, value)
End If
which removes those attributes.
But that also means it does not write them if I specify them. How can I add those two empty namespaces to the class using attributes ?
I changed it to
<System.Xml.Serialization.XmlRoot("ccl", Namespace:="")> _
but that doesn't seem to work.