0
I am generating an xml of an Nfse, but I need everything generated in a single line, even when generating the signature. When I serialize, I do it this way:
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
XmlSerializer ser = new XmlSerializer(typeof(GerarNfseEnvio));
FileStream arquivo = new FileStream("E:\\nota.xml", FileMode.CreateNew);
xsn.Add("", "http://www.abrasf.org.br/nfse.xsd");
arquivo.Flush();
ser.Serialize(arquivo, gerar, xsn);
arquivo.Close();
But it is identado and in several lines, I need everything in a single line, because the way I am doing, I need to create a new file for each change, and I do this way:
using (var writer = System.IO.File.CreateText("E:\\notasemesp.xml"))
{
var doc = new XmlDocument { PreserveWhitespace = false };
doc.Load("E:\\nota.xml");
writer.WriteLine(doc.InnerXml);
writer.Flush();
}
Only that it is impracticable, create a new file, for new change, since until the end is made 3 changes, then would be necessary to create another 3 xml, how can I fix this problem? Example: The way I serialize it is this way:
<Rps>
<IdentificacaoRps>
<Numero>1</Numero>
<Serie>999</Serie>
<Tipo>1</Tipo>
</IdentificacaoRps>
<DataEmissao>2018-11-27</DataEmissao>
<Status>1</Status>
I need every change I use Save
, stay that way:
<Rps><IdentificacaoRps><Numero>1</Numero><Serie>999</Serie><Tipo>1</Tipo</IdentificacaoRps><DataEmissao>2018-11-27</DataEmissao<Status>1</Status></Rps>
It worked fine, thank you.
– Mariana