After Serialzation, object to a string
I am getting the current xml
<obj>
...
<field p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance"/>
...
</obj>
the field is nullable so i am waiting for an xsi:nill , instead i am getting p2:nill why?
When building an XmlSerializer you can control the namespaces, if you don't random(ish) names will be applied. Try seeing if something like this helps
var ns = new XmlSerializerNamespaces();
ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
var ser = new XmlSerializer(typeof(AnEntity));
ser.Serialize(Console.Out, new AnEntity(), ns);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.