J'ai ce type :
[Serializable, DataContract]
public class A
{
[DataMember(Order = 1)]
public int P1 { get; set; }
[DataMember(Order = 2)]
public XmlSerializableDictionary<string, string> P2 { get; set; }
}
Dónde XmlSerializableDictionary
est emprunté à Les problèmes de sérialisation XML de .NET ? .
En XmlSerializer
produit le XML suivant :
<?xml version="1.0"?>
<A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<P1>17</P1>
<P2>
<item>
<key>
<string>Hello World!</string>
</key>
<value>
<string>xo-xo</string>
</value>
</item>
<item>
<key>
<string>Good Bye!</string>
</key>
<value>
<string>xi-xi</string>
</value>
</item>
</P2>
</A>
Les seules choses dont je souhaite me débarrasser sont les déclarations xmlns sur l'élément Root. Comment dois-je m'y prendre ? Merci.