I was serializing a file and it worked normally, but now, when serializing q1 appears in all tags, I'm doing this:
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
XmlSerializer ser = new XmlSerializer(typeof(GerarNfseEnvio));
FileStream arquivo = new FileStream("E:\NFSe-" + "RPS" + numero.ToString().PadLeft(15, '0') + ".xml", FileMode.CreateNew);
if (item.CodigoMunicipio == 3107109)
{
xsn.Add("", "http://www.betha.com.br/e-nota-contribuinte-ws");
}
else
{
xsn.Add("", "http://www.abrasf.org.br/nfse.xsd");
}
ser.Serialize(arquivo, gerar, xsn);
arquivo.Close();
It worked perfectly, but now the tags appear like this:
<q1:GerarNfseEnvio xmlns="http://www.betha.com.br/e-nota-contribuinte-ws" xmlns:q1="http://www.abrasf.org.br/nfse.xsd">
It's adding the two, only when I leave only the xsn.Add("", "http://www.abrasf.org.br/nfse.xsd");
line that works. It was working perfectly. After adding the if statement, it was this way. How to correct?