-2

I have this code, how I can remove the namespace from output xml

MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(OrderTable));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, null);
xs.Serialize(xmlTextWriter, ot);
string result = Encoding.Default.GetString(memoryStream.ToArray());



<?xml version="1.0" ?> 
- <OrderTable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ForceUpdate>false</ForceUpdate> 
  <TableId xsi:nil="true" /> 
  <UpdatedBy>Jack</UpdatedBy> 
  </OrderTable>

I want to remove xmlns, I googled, but those are not helping me.

iVikashJha
  • 159
  • 1
  • 2
  • 14

1 Answers1

1

I want to remove xmlns

All you have to do is using XmlSerializerNamespaces

var ns = new XmlSerializerNamespaces();
ns.Add("", "");
xs.Serialize(xmlTextWriter, ot, ns);
Eser
  • 12,346
  • 1
  • 22
  • 32