0
I get an Nfse XML, but I need to handle the special characters, example: ´^~Ç
etc, I serializo 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:\\NFSe-" + "RPS" +
numero.ToString().PadLeft(15, '0') +
".xml", FileMode.CreateNew);
xsn.Add("", "http://www.abrasf.org.br/nfse.xsd");
ser.Serialize(arquivo, gerar, xsn);
arquivo.Close();
Instead of treating field by field, there is some way to change when creating the XML
Yeah, I’ll take it all at once?
EDIT
I Gero an xml for example with tags, for example
<Discriminacao>Relógio Henry-250\s\nDescrição 62-29\s\n</Discriminacao>
It cannot have accents, Ç etc. It should come out this way:
<Discriminacao>Relogio Henry-250\s\nDescricao 62-29\s\n</Discriminacao>
I want to handle the whole xml, because it’s a lot of fields.
This line is when I serializo the xml
:
ser.Serialize(arquivo, gerar, xsn);
I was wondering if it was possible before serializing, or when serializing, to remove the special characters.
EDIT
I pass the fields this way
gerar.Rps.InfDeclaracaoPrestacaoServico.Tomador.Endereco.Endereco =
tomador.EnderecoCobranca.Trim();
But I didn’t want to put the function in each field, because there are many, I wanted to know if there is any way to do this when generating the xml, when serialize or load it and replace, something like.
Make available in your question a copy of the file! an Example can not understand
– novic
@Virgilionovic I edited to clarify.
– Mariana
Mariana needs to generate this data without accentuation and/or special characters, for what reason?
– novic
When I sign/send XML, it does not accept if it has special characters.
– Mariana
On the site itself you can remove this: https://answall.com/questions/2/como-fa%C3%A7o-to-remove-accents-in-a-string look are just a few examples
– novic
Data comes in a class or list of that class?
– novic
The data comes from a class, and from a class list, are two types. I’ll take a look.
– Mariana
I needed to understand what is really what you have in information
– novic
@Virgilionovic I Gero an xml, and I need that when passing the data, take the special characters, because if I do by field, by field, it will be a lot of work, because NF-e have several fields, so I wanted to know if you have a way to do this when generating xml.
– Mariana
You have to exemplify the data before generating the XML so we can take a north! so it gets complicated I know which is the die, maybe the problem is before and can be solved easier
– novic
@Virgilionovic I create an xml, passing the data through a schema, to serialize, which would be the xml of Nfse, to generate I inform the value for each field, instead of using replace in each field, I wanted to see if there is any way to do, whether to serialize, when loading xml and replace, there are many fields on a bill, so I wanted to see if there was any way. Was it not clear ? I edited the answer of how I pass the data, to see if it becomes clearer.
– Mariana
Mariana, what is the example of the type of data, what is the class, explains all this in the question, is not that it was not clear, is that your question does not explain how you do actually! Put an example of the class, and how you manipulate the data in it
– novic
It is of a class schema, I put an example in the question, and in the question there was already the form that I create, and serializo the class. Are of type string the data.
– Mariana
gerar
is the name of the object and the class?– novic
You set the generation, but you didn’t set an example of the class! it’s complicated to say if you want to streamline your code by making the class do this character swap for you, always be objective in the questions and clear ...
– novic
Generate is the name of the object, where I pass the serialized data. The class is huge because it’s the class of an xsd, if you want me to put it in one piece, I can put it, but I don’t think it will solve.
– Mariana
Another thing, if you don’t specify a solution I think it’s a duplicate of this: https://answall.com/questions/2/como-fa%C3%A7o-to-remove-accents-in-a-string because it already shows you how to exchange accented characters for accents.
– novic
Let’s go continue this discussion in chat.
– novic