0
I am working on an Nfe project, and have chosen to use serialization of a class based on the xml structure I want. I implemented the class, everything worked as expected, root, nodes etc, but I have a problem, referring to order my elements in the output xml
This is my class that I serializo:
public class nfeProc
{
public infNFe infnfe;
}
public class infNFe
{
public ide ide;
public emit emit;
}
public class ide
{
public string cUF { get; set; }
public string cNF { get; set; }
public string natOp { get; set; }
public string indPag { get; set; }
public string mod { get; set; }
public string serie { get; set; }
public string nNF { get; set; }
public string dEmi { get; set; }
public string tpNF { get; set; }
public string cMunFG { get; set; }
public string tpImp { get; set; }
public string tpEmis { get; set; }
public string cDV { get; set; }
public string tpAmb { get; set; }
public string finNFe { get; set; }
public string procEmi { get; set; }
public string verProc { get; set; }
}
public class emit
{
public string CNPJ { get; set; }
public string xNome { get; set; }
public string xFant { get; set; }
public enderEmit enderEmit;
public string IE { get; set; }
public string CRT { get; set; }
}
public class enderEmit{
public string xLgr { get; set; }
public string nro { get; set; }
public string xCpl { get; set; }
public string xBairro { get; set; }
public string cMun { get; set; }
public string xMun { get; set; }
public string UF { get; set; }
public string CEP { get; set; }
public string cPais { get; set; }
public string xPais { get; set; }
}
This is my example output, without some elements just to exemplify:
<nfeProc>
<infnfe>
<ide>
<natOp>HUEHUEBR</natOp>
<mod>HUEHUEBR</mod>
<nNF>HUEHUEBR</nNF>
</ide>
<emit>
<enderEmit>
<CEP>04858480</CEP>
<cPais>55</cPais>
</enderEmit>
<xNome>USHAUSHAUSHUA</xNome>
<xFant>USHAUSHAUSHUA</xFant>
<IE>USHAUSHAUSHUA</IE>
<CRT>USHAUSHAUSHUA</CRT>
</emit>
</infnfe>
</nfeProc>
And my problem is the order of the elements, I can’t manipulate them enderEmit
goes below some elements determined by me. Example two (xNome
and xFant
):
<nfeProc>
<infnfe>
<ide>
<natOp>HUEHUEBR</natOp>
<mod>HUEHUEBR</mod>
<nNF>HUEHUEBR</nNF>
</ide>
<emit>
<xNome>USHAUSHAUSHUA</xNome>
<xFant>USHAUSHAUSHUA</xFant>
<enderEmit>
<CEP>04858480</CEP>
<cPais>55</cPais>
</enderEmit>
<IE>USHAUSHAUSHUA</IE>
<CRT>USHAUSHAUSHUA</CRT>
</emit>
</infnfe>
</nfeProc>
That’s what got the help !
– bp002