0

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?

shay
  • 2,021
  • 1
  • 15
  • 17

1 Answers1

0

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);
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56