Inquiridor
XML NFe - Deserialize

Pergunta
-
Boa tarde.
Preciso "pegar" os dados de cada item do produto em um XML de uma NFe e para isso estou usando o XmlSerializer (Deserialize). Porém, não estou conseguindo ler os impostos de cada item, sendo que o produto, código, etc... do produto, estou conseguindo (abaixo codigo). Caso alguém posso me ajudar, agradeço.
Segue código que estou usando para ler o XML:
XmlDocument arquivo = new XmlDocument(); arquivo.Load(arquivoXML); var totalItens = arquivo.GetElementsByTagName("prod"); TextReader textReader = (TextReader)new StreamReader(arquivoXML); XmlTextReader reader = new XmlTextReader(textReader); reader.Read(); XmlSerializer ser = new XmlSerializer(typeof(TNfeProc)); TNfeProc nota = (TNfeProc)ser.Deserialize(reader); // conta qtos itens tem na NFe para fazer o while int itensNF = 0; foreach (XmlElement nodo in totalItens) { itensNF++; } int item = 0; while (item < itensNF) { textFrete.Text = nota.NFe.infNFe.det[item].prod.vFrete; item++; }
Agra
Jones Palmitos-SC
Todas as Respostas
-
Olá
Espero que ajude a rotina como eu fiz aqui.
eu tento primeiro desserializar para minha classe, mas as vezes ocorre erro nesta desserialização e ai tenho que ler o xml e atribuir dados aos objetos:
ATENÇÃO: A rotina ficou extensa, então estou fazendo em dois posts
XmlNodeList NFe = aDoc.GetElementsByTagName("NFe"); XmlNodeList infNFe = ((XmlElement)NFe[0]).GetElementsByTagName("infNFe"); XmlNodeList infNFe_ide = ((XmlElement)infNFe[0]).GetElementsByTagName("ide"); XmlNodeList infNFe_emit = ((XmlElement)infNFe[0]).GetElementsByTagName("emit"); XmlNodeList infNFe_emit_enderEmit = ((XmlElement)infNFe_emit[0]).GetElementsByTagName("enderEmit"); XmlNodeList infNFe_dest = ((XmlElement)infNFe[0]).GetElementsByTagName("dest"); XmlNodeList infNFe_dest_enderdest = ((XmlElement)infNFe_dest[0]).GetElementsByTagName("enderDest"); XmlNodeList infNFe_local_retirada = ((XmlElement)infNFe[0]).GetElementsByTagName("retirada"); XmlNodeList infNFe_local_entrega = ((XmlElement)infNFe[0]).GetElementsByTagName("entrega"); XmlNodeList infNFe_det = ((XmlElement)infNFe[0]).GetElementsByTagName("det"); XmlNodeList infNFe_total = ((XmlElement)infNFe[0]).GetElementsByTagName("total"); XmlNodeList nfe_NfeProc = ((XmlElement)NFe[0]).GetElementsByTagName("protNFe"); foreach (XmlElement nodo in infNFe_det) { #region NFE.DET if (contador == 0) _TNfeProc.NFe.infNFe.det = new WinUi.Classes.PROCNFE310.TNFeInfNFeDet[infNFe_det.Count]; _TNfeProc.NFe.infNFe.det[contador] = new WinUi.Classes.PROCNFE310.TNFeInfNFeDet(); _TNfeProc.NFe.infNFe.det[contador].prod = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetProd(); _TNfeProc.NFe.infNFe.det[contador].imposto = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImposto(); if (nodo.Attributes["infAdProd"] != null) _TNfeProc.NFe.infNFe.det[contador].infAdProd = nodo.Attributes["nItem"].ToString(); _TNfeProc.NFe.infNFe.det[contador].nItem = nodo.Attributes["nItem"].ToString(); XmlNodeList infNFe_det_prod = ((XmlElement)nodo).GetElementsByTagName("prod"); foreach (XmlElement nodo1 in infNFe_det_prod) { #region det produto if (nodo1.GetElementsByTagName("cProd")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.cProd = nodo1.GetElementsByTagName("cProd")[0].InnerText; if (nodo1.GetElementsByTagName("cEAN")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.cEAN = nodo1.GetElementsByTagName("cEAN")[0].InnerText; if (nodo1.GetElementsByTagName("xProd")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.xProd = nodo1.GetElementsByTagName("xProd")[0].InnerText; if (nodo1.GetElementsByTagName("NCM")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.NCM = nodo1.GetElementsByTagName("NCM")[0].InnerText; if (nodo1.GetElementsByTagName("EXTIPI")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.EXTIPI = nodo1.GetElementsByTagName("EXTIPI")[0].InnerText; if (nodo1.GetElementsByTagName("CFOP")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.CFOP = (WinUi.Classes.PROCNFE310.TCfop)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Tpais), nodo1.GetElementsByTagName("CFOP")[0].InnerText); if (nodo1.GetElementsByTagName("uCom")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.uCom = nodo1.GetElementsByTagName("uCom")[0].InnerText; if (nodo1.GetElementsByTagName("qCom")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.qCom = nodo1.GetElementsByTagName("qCom")[0].InnerText; if (nodo1.GetElementsByTagName("vUnCom")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vUnCom = nodo1.GetElementsByTagName("vUnCom")[0].InnerText; if (nodo1.GetElementsByTagName("vProd")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vProd = nodo1.GetElementsByTagName("vProd")[0].InnerText; if (nodo1.GetElementsByTagName("cEANTrib")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.cEANTrib = nodo1.GetElementsByTagName("cEANTrib")[0].InnerText; if (nodo1.GetElementsByTagName("uTrib")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.uTrib = nodo1.GetElementsByTagName("uTrib")[0].InnerText; if (nodo1.GetElementsByTagName("qTrib")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.qTrib = nodo1.GetElementsByTagName("qTrib")[0].InnerText; if (nodo1.GetElementsByTagName("vUnTrib")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vUnTrib = nodo1.GetElementsByTagName("vUnTrib")[0].InnerText; if (nodo1.GetElementsByTagName("vFrete")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vFrete = nodo1.GetElementsByTagName("vFrete")[0].InnerText; if (nodo1.GetElementsByTagName("vSeg")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vSeg = nodo1.GetElementsByTagName("vSeg")[0].InnerText; if (nodo1.GetElementsByTagName("vDesc")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vDesc = nodo1.GetElementsByTagName("vDesc")[0].InnerText; if (nodo1.GetElementsByTagName("vOutro")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vOutro = nodo1.GetElementsByTagName("vOutro")[0].InnerText; if (nodo1.GetElementsByTagName("indTot")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.indTot = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetProdIndTot)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetProdIndTot), nodo1.GetElementsByTagName("indTot")[0].InnerText); if (nodo1.GetElementsByTagName("xPed")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.xPed = nodo1.GetElementsByTagName("xPed")[0].InnerText; if (nodo1.GetElementsByTagName("nItemPed")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.nItemPed = nodo1.GetElementsByTagName("nItemPed")[0].InnerText; if (nodo1.GetElementsByTagName("nFCI")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.nFCI = nodo1.GetElementsByTagName("nFCI")[0].InnerText; if (nodo1.GetElementsByTagName("vOutro")[0] != null) _TNfeProc.NFe.infNFe.det[contador].prod.vOutro = nodo1.GetElementsByTagName("vOutro")[0].InnerText; #endregion det produto } XmlNodeList infNFe_det_Imposto = ((XmlElement)nodo).GetElementsByTagName("imposto"); //_TNfeProc.NFe.infNFe.det[contador].imposto = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImposto(); contador1 = 0; XmlNodeList infNFe_det_Imposto_Items = null; foreach (XmlElement nodo1 in infNFe_det_Imposto) { //if (nodo1.GetElementsByTagName("PIS")[0] != null) contador1++; if (nodo1.GetElementsByTagName("ICMS")[0] != null) contador1++; if (nodo1.GetElementsByTagName("II")[0] != null) contador1++; if (nodo1.GetElementsByTagName("IPI")[0] != null) contador1++; if (nodo1.GetElementsByTagName("ISSQN")[0] != null) contador1++; //if (nodo1.GetElementsByTagName("COFINS")[0] != null) contador1++; //if (nodo1.GetElementsByTagName("COFINSST")[0] != null) contador1++; } if (contador1 > 0) _TNfeProc.NFe.infNFe.det[contador].imposto.Items = new object[contador1]; foreach (XmlElement nodo1 in infNFe_det_Imposto) { #region NFE.DET.IMPOSTO if (nodo1.GetElementsByTagName("vTotTrib")[0] != null) _TNfeProc.NFe.infNFe.det[contador].imposto.vTotTrib = nodo1.GetElementsByTagName("vTotTrib")[0].InnerText; contador1 = 0; #region det.imposto.PIS if (nodo1.GetElementsByTagName("PIS")[0] != null) { _TNfeProc.NFe.infNFe.det[contador].imposto.PIS = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPIS(); WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPIS pis = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPIS(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("PIS"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("PISAliq")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISAliq PISAliq = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISAliq(); if (nodo2.GetElementsByTagName("CST")[0] != null) PISAliq.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISAliqCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISAliqCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) PISAliq.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pPIS")[0] != null) PISAliq.pPIS = nodo2.GetElementsByTagName("pPIS")[0].InnerText; if (nodo2.GetElementsByTagName("vPIS")[0] != null) PISAliq.vPIS = nodo2.GetElementsByTagName("vPIS")[0].InnerText; if (nodo2.GetElementsByTagName("vBC")[0] != null) PISAliq.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("vBC")[0] != null) PISAliq.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; pis.Item = PISAliq; } if (nodo2.GetElementsByTagName("PISNT")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISNT PISNT = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISNT(); if (nodo2.GetElementsByTagName("CST")[0] != null) PISNT.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISNTCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISNTCST), nodo2.GetElementsByTagName("CST")[0].InnerText); pis.Item = PISNT; } if (nodo2.GetElementsByTagName("PISOutr")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISOutr PISOutr = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISOutr(); if (nodo2.GetElementsByTagName("CST")[0] != null) PISOutr.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISOutrCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISOutrCST), nodo2.GetElementsByTagName("CST")[0].InnerText); pis.Item = PISOutr; } if (nodo2.GetElementsByTagName("PISQtde")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISQtde PISQtde = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISQtde(); if (nodo2.GetElementsByTagName("CST")[0] != null) PISQtde.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISQtdeCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISPISQtdeCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("qBCProd")[0] != null) PISQtde.qBCProd = nodo2.GetElementsByTagName("qBCProd")[0].InnerText; if (nodo2.GetElementsByTagName("vAliqProd")[0] != null) PISQtde.vAliqProd = nodo2.GetElementsByTagName("vAliqProd")[0].InnerText; if (nodo2.GetElementsByTagName("vPIS")[0] != null) PISQtde.vAliqProd = nodo2.GetElementsByTagName("vPIS")[0].InnerText; pis.Item = PISQtde; } _TNfeProc.NFe.infNFe.det[contador].imposto.PIS = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPIS(); _TNfeProc.NFe.infNFe.det[contador].imposto.PIS = pis; } } #endregion det.imposto.PIS #region det.imposto.PISST if (nodo1.GetElementsByTagName("PISST")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISST pisSt = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISST(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("PISST"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("vPIS")[0] != null) pisSt.vPIS = nodo2.GetElementsByTagName("vPIS")[0].InnerText; } _TNfeProc.NFe.infNFe.det[contador].imposto.PISST = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoPISST(); _TNfeProc.NFe.infNFe.det[contador].imposto.PISST = pisSt; } #endregion det.imposto.PISST #region det.imposto.COFINS if (nodo1.GetElementsByTagName("COFINS")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINS cofins = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINS(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("COFINS"); contador2 = 0; foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("COFINSAliq")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSAliq COFINSAliq = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSAliq(); if (nodo2.GetElementsByTagName("CST")[0] != null) COFINSAliq.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSAliqCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSAliqCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) COFINSAliq.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pCOFINS")[0] != null) COFINSAliq.pCOFINS = nodo2.GetElementsByTagName("pCOFINS")[0].InnerText; if (nodo2.GetElementsByTagName("vCOFINS")[0] != null) COFINSAliq.vCOFINS = nodo2.GetElementsByTagName("vCOFINS")[0].InnerText; cofins.Item = COFINSAliq; } if (nodo2.GetElementsByTagName("COFINSNT")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSNT COFINSNT = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSNT(); if (nodo2.GetElementsByTagName("CST")[0] != null) COFINSNT.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSNTCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSNTCST), nodo2.GetElementsByTagName("CST")[0].InnerText); cofins.Item = COFINSNT; } if (nodo2.GetElementsByTagName("COFINSOutr")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSOutr COFINSOutr = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSOutr(); contador2 = 0; if (nodo2.GetElementsByTagName("CST")[0] != null) COFINSOutr.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSOutrCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSOutrCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("pCOFINS")[0] != null) contador2++; if (nodo2.GetElementsByTagName("qBCProd")[0] != null) contador2++; if (nodo2.GetElementsByTagName("vAliqProd")[0] != null) contador2++; if (nodo2.GetElementsByTagName("vBC")[0] != null) contador2++; COFINSOutr.Items = new string[contador2]; COFINSOutr.ItemsElementName = new WinUi.Classes.PROCNFE310.ItemsChoiceType3[contador2]; contador2 = 0; if (nodo2.GetElementsByTagName("pCOFINS")[0] != null) { COFINSOutr.Items[contador2] = nodo2.GetElementsByTagName("pCOFINS")[0].InnerText; COFINSOutr.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType3) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "pCOFINS"); contador2++; } if (nodo2.GetElementsByTagName("qBCProd")[0] != null) { COFINSOutr.Items[contador2] = nodo2.GetElementsByTagName("qBCProd")[0].InnerText; COFINSOutr.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType3) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "qBCProd"); contador2++; } if (nodo2.GetElementsByTagName("vAliqProd")[0] != null) { COFINSOutr.Items[contador2] = nodo2.GetElementsByTagName("vAliqProd")[0].InnerText; COFINSOutr.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType3) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "vAliqProd"); contador2++; } if (nodo2.GetElementsByTagName("vBC")[0] != null) { COFINSOutr.Items[contador2] = nodo2.GetElementsByTagName("vBC")[0].InnerText; COFINSOutr.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType3) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "vBC"); contador2++; } if (nodo2.GetElementsByTagName("vCOFINS")[0] != null) COFINSOutr.vCOFINS = nodo2.GetElementsByTagName("vCOFINS")[0].InnerText; cofins.Item = COFINSOutr; } if (nodo2.GetElementsByTagName("COFINSQtde")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSQtde COFINSQtde = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSQtde(); if (nodo2.GetElementsByTagName("CST")[0] != null) COFINSQtde.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSQtdeCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSCOFINSQtdeCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("qBCProd")[0] != null) COFINSQtde.qBCProd = nodo2.GetElementsByTagName("qBCProd")[0].InnerText; if (nodo2.GetElementsByTagName("vAliqProd")[0] != null) COFINSQtde.vAliqProd = nodo2.GetElementsByTagName("vAliqProd")[0].InnerText; if (nodo2.GetElementsByTagName("vCOFINS")[0] != null) COFINSQtde.vCOFINS = nodo2.GetElementsByTagName("vCOFINS")[0].InnerText; cofins.Item = COFINSQtde; } } _TNfeProc.NFe.infNFe.det[contador].imposto.COFINS = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINS(); _TNfeProc.NFe.infNFe.det[contador].imposto.COFINS = cofins; } #endregion det.imposto.COFINS #region det.imposto.COFINSST if (nodo1.GetElementsByTagName("COFINSST")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSST cofinsST = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSST(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("COFINSST"); contador2 = 0; foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("pCOFINS")[0] != null) contador2++; if (nodo2.GetElementsByTagName("qBCProd")[0] != null) contador2++; if (nodo2.GetElementsByTagName("vAliqProd")[0] != null) contador2++; if (nodo2.GetElementsByTagName("vBC")[0] != null) contador2++; } cofinsST.Items = new string[contador2]; cofinsST.ItemsElementName = new WinUi.Classes.PROCNFE310.ItemsChoiceType4[contador2]; contador2 = 0; if (nodo1.GetElementsByTagName("pCOFINS")[0] != null) { cofinsST.Items[contador2] = nodo1.GetElementsByTagName("pCOFINS")[0].InnerText; cofinsST.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType4) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType4), "pCOFINS"); contador2++; } if (nodo1.GetElementsByTagName("qBCProd")[0] != null) { cofinsST.Items[contador2] = nodo1.GetElementsByTagName("qBCProd")[0].InnerText; cofinsST.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType4) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "qBCProd"); contador2++; } if (nodo1.GetElementsByTagName("vAliqProd")[0] != null) { cofinsST.Items[contador2] = nodo1.GetElementsByTagName("vAliqProd")[0].InnerText; cofinsST.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType4) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "vAliqProd"); contador2++; } if (nodo1.GetElementsByTagName("vBC")[0] != null) { cofinsST.Items[contador2] = nodo1.GetElementsByTagName("vBC")[0].InnerText; cofinsST.ItemsElementName[contador2] = (WinUi.Classes.PROCNFE310.ItemsChoiceType4) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.ItemsChoiceType3), "vBC"); contador2++; } if (nodo1.GetElementsByTagName("vCOFINS")[0] != null) cofinsST.vCOFINS = nodo1.GetElementsByTagName("vCOFINS")[0].InnerText; _TNfeProc.NFe.infNFe.det[contador].imposto.COFINSST = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoCOFINSST(); _TNfeProc.NFe.infNFe.det[contador].imposto.COFINSST = cofinsST; } #endregion det.imposto.COFINSST
Continua no proximo post
-
continuação
#region det.imposto.ICMS if (nodo1.GetElementsByTagName("ICMS")[0] != null) { //_TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = new object(); WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMS icms = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMS(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("ICMS"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("ICMS00")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00 icms00 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms00.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms00.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icms00.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS00ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) icms00.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms00.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms00.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; icms.Item = icms00; } if (nodo2.GetElementsByTagName("ICMS10")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10 icms10 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms10.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms10.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icms10.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) icms10.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms10.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms10.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("modBCST")[0] != null) icms10.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS10ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icms10.vICMS = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icms10.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icms10.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icms10.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icms10.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; icms.Item = icms10; } if (nodo2.GetElementsByTagName("ICMS20")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20 icms20 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms20.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms20.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icms20.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icms20.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("vBC")[0] != null) icms20.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms20.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms20.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSDeson")[0] != null) icms20.vICMSDeson = nodo2.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icms20.motDesICMS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20MotDesICMS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS20MotDesICMS), nodo2.GetElementsByTagName("motDesICMS")[0].InnerText); icms.Item = icms20; } if (nodo2.GetElementsByTagName("ICMS30")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30 icms30 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms30.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms30.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBCST")[0] != null) icms30.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icms30.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icms30.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icms30.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icms30.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icms30.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSDeson")[0] != null) icms30.vICMSDeson = nodo2.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icms30.motDesICMS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30MotDesICMS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS30MotDesICMS), nodo2.GetElementsByTagName("motDesICMS")[0].InnerText); icms.Item = icms30; } else if (nodo2.GetElementsByTagName("ICMS40")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40 icms40 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms40.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms40.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("vICMSDeson")[0] != null) icms40.vICMSDeson = nodo2.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icms40.motDesICMS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40MotDesICMS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS40MotDesICMS), nodo2.GetElementsByTagName("motDesICMS")[0].InnerText); icms.Item = icms40; } else if (nodo2.GetElementsByTagName("ICMS51")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51 icms51 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms51.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms51.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) { icms51.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS51ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); icms51.modBCSpecified = true; } if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icms51.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("vBC")[0] != null) icms51.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms51.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSOp")[0] != null) icms51.vICMSOp = nodo2.GetElementsByTagName("vICMSOp")[0].InnerText; if (nodo2.GetElementsByTagName("pDif")[0] != null) icms51.pDif = nodo2.GetElementsByTagName("pDif")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSDif")[0] != null) icms51.vICMSDif = nodo2.GetElementsByTagName("vICMSDif")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms51.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; icms.Item = icms51; } else if (nodo2.GetElementsByTagName("ICMS60")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS60 icms60 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS60(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms60.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms60.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS60CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS60CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("vBCSTRet")[0] != null) icms60.vBCSTRet = nodo2.GetElementsByTagName("vBCSTRet")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSSTRet")[0] != null) icms60.vICMSSTRet = nodo2.GetElementsByTagName("vICMSSTRet")[0].InnerText; icms.Item = icms60; } else if (nodo2.GetElementsByTagName("ICMS70")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70 icms70 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms70.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms70.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icms70.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icms70.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("vBC")[0] != null) icms70.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms70.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms70.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("modBCST")[0] != null) icms70.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icms70.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icms70.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icms70.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icms70.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icms70.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSDeson")[0] != null) icms70.vICMSDeson = nodo2.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icms70.motDesICMS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70MotDesICMS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS70MotDesICMS), nodo2.GetElementsByTagName("motDesICMS")[0].InnerText); icms.Item = icms70; } else if (nodo2.GetElementsByTagName("ICMS90")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90 icms90 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90(); if (nodo2.GetElementsByTagName("orig")[0] != null) icms90.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icms90.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90CST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90CST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icms90.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) icms90.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icms90.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icms90.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icms90.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("modBCST")[0] != null) icms90.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icms90.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icms90.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icms90.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icms90.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icms90.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSDeson")[0] != null) icms90.vICMSDeson = nodo2.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icms90.motDesICMS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90MotDesICMS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMS90MotDesICMS), nodo2.GetElementsByTagName("motDesICMS")[0].InnerText); icms.Item = icms90; } else if (nodo2.GetElementsByTagName("ICMSPart")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPart icmsPart = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPart(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmsPart.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icmsPart.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icmsPart.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) icmsPart.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icmsPart.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icmsPart.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icmsPart.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("modBCST")[0] != null) icmsPart.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSPartModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icmsPart.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icmsPart.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icmsPart.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icmsPart.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icmsPart.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("pBCOp")[0] != null) icmsPart.pBCOp = nodo2.GetElementsByTagName("pBCOp")[0].InnerText; if (nodo2.GetElementsByTagName("motDesICMS")[0] != null) icmsPart.UFST = (WinUi.Classes.PROCNFE310.TUf) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TUf), nodo2.GetElementsByTagName("UFST")[0].InnerText); icms.Item = icmsPart; } else if (nodo2.GetElementsByTagName("ICMSSN101")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN101 icmsSn101 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN101(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmsSn101.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icmsSn101.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN101CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN101CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); if (nodo2.GetElementsByTagName("pCredSN")[0] != null) icmsSn101.pCredSN = nodo2.GetElementsByTagName("pCredSN")[0].InnerText; if (nodo2.GetElementsByTagName("vCredICMSSN")[0] != null) icmsSn101.vCredICMSSN = nodo2.GetElementsByTagName("vCredICMSSN")[0].InnerText; icms.Item = icmsSn101; } else if (nodo2.GetElementsByTagName("ICMSSN102")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN102 icmsSn102 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN102(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmsSn102.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CSOSN")[0] != null) icmsSn102.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN102CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN102CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); icms.Item = icmsSn102; } else if (nodo2.GetElementsByTagName("ICMSSN201")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201 icmssn201 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmssn201.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CSOSN")[0] != null) icmssn201.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); if (nodo2.GetElementsByTagName("modBCST")[0] != null) icmssn201.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN201ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icmssn201.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icmssn201.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icmssn201.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icmssn201.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icmssn201.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("pCredSN")[0] != null) icmssn201.pCredSN = nodo2.GetElementsByTagName("pCredSN")[0].InnerText; if (nodo2.GetElementsByTagName("vCredICMSSN")[0] != null) icmssn201.vCredICMSSN = nodo2.GetElementsByTagName("vCredICMSSN")[0].InnerText; icms.Item = icmssn201; } else if (nodo2.GetElementsByTagName("ICMSSN202")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202 icmssn202 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmssn202.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CSOSN")[0] != null) icmssn202.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); if (nodo2.GetElementsByTagName("modBCST")[0] != null) icmssn202.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN202ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icmssn202.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icmssn202.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icmssn202.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icmssn202.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icmssn202.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; icms.Item = icmssn202; } else if (nodo2.GetElementsByTagName("ICMSSN500")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN500 icmssn500 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN500(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmssn500.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CSOSN")[0] != null) icmssn500.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN500CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN500CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); if (nodo2.GetElementsByTagName("vBCSTRet")[0] != null) icmssn500.vBCSTRet = nodo2.GetElementsByTagName("vBCSTRet")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSSTRet")[0] != null) icmssn500.vICMSSTRet = nodo2.GetElementsByTagName("vICMSSTRet")[0].InnerText; icms.Item = icmssn500; } else if (nodo2.GetElementsByTagName("ICMSSN900")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900 icmsSn900 = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmsSn900.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CSOSN")[0] != null) icmsSn900.CSOSN = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900CSOSN) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900CSOSN), nodo2.GetElementsByTagName("CSOSN")[0].InnerText); if (nodo2.GetElementsByTagName("modBC")[0] != null) icmsSn900.modBC = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900ModBC) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900ModBC), nodo2.GetElementsByTagName("modBC")[0].InnerText); if (nodo2.GetElementsByTagName("vBC")[0] != null) icmsSn900.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBC")[0] != null) icmsSn900.pRedBC = nodo2.GetElementsByTagName("pRedBC")[0].InnerText; if (nodo2.GetElementsByTagName("pICMS")[0] != null) icmsSn900.pICMS = nodo2.GetElementsByTagName("pICMS")[0].InnerText; if (nodo2.GetElementsByTagName("vICMS")[0] != null) icmsSn900.vICMS = nodo2.GetElementsByTagName("vICMS")[0].InnerText; if (nodo2.GetElementsByTagName("modBCST")[0] != null) icmsSn900.modBCST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900ModBCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSN900ModBCST), nodo2.GetElementsByTagName("modBCST")[0].InnerText); if (nodo2.GetElementsByTagName("pMVAST")[0] != null) icmsSn900.pMVAST = nodo2.GetElementsByTagName("pMVAST")[0].InnerText; if (nodo2.GetElementsByTagName("pRedBCST")[0] != null) icmsSn900.pRedBCST = nodo2.GetElementsByTagName("pRedBCST")[0].InnerText; if (nodo2.GetElementsByTagName("vBCST")[0] != null) icmsSn900.vBCST = nodo2.GetElementsByTagName("vBCST")[0].InnerText; if (nodo2.GetElementsByTagName("pICMSST")[0] != null) icmsSn900.pICMSST = nodo2.GetElementsByTagName("pICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSST")[0] != null) icmsSn900.vICMSST = nodo2.GetElementsByTagName("vICMSST")[0].InnerText; if (nodo2.GetElementsByTagName("pCredSN")[0] != null) icmsSn900.pCredSN = nodo2.GetElementsByTagName("pCredSN")[0].InnerText; if (nodo2.GetElementsByTagName("vCredICMSSN")[0] != null) icmsSn900.vCredICMSSN = nodo2.GetElementsByTagName("vCredICMSSN")[0].InnerText; icms.Item = icmsSn900; } else if (nodo2.GetElementsByTagName("ICMSST")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSST icmsSt = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSST(); if (nodo2.GetElementsByTagName("orig")[0] != null) icmsSt.orig = (WinUi.Classes.PROCNFE310.Torig)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Torig), nodo2.GetElementsByTagName("orig")[0].InnerText); if (nodo2.GetElementsByTagName("CST")[0] != null) icmsSt.CST = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSTCST) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoICMSICMSSTCST), nodo2.GetElementsByTagName("CST")[0].InnerText); if (nodo2.GetElementsByTagName("vBCSTRet")[0] != null) icmsSt.vBCSTRet = nodo2.GetElementsByTagName("vBCSTRet")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSSTRet")[0] != null) icmsSt.vICMSSTRet = nodo2.GetElementsByTagName("vICMSSTRet")[0].InnerText; if (nodo2.GetElementsByTagName("vBCSTDest")[0] != null) icmsSt.vICMSSTRet = nodo2.GetElementsByTagName("vBCSTDest")[0].InnerText; if (nodo2.GetElementsByTagName("vICMSSTDest")[0] != null) icmsSt.vICMSSTRet = nodo2.GetElementsByTagName("vICMSSTDest")[0].InnerText; icms.Item = icmsSt; } } _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = new object(); _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = icms; contador1++; } #endregion det.imposto.ICMS #region det.imposto.II if (nodo1.GetElementsByTagName("II")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoII ii = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoII(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("II"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("vBC")[0] != null) ii.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("vDespAdu")[0] != null) ii.vDespAdu = nodo2.GetElementsByTagName("vDespAdu")[0].InnerText; if (nodo2.GetElementsByTagName("vII")[0] != null) ii.vII = nodo2.GetElementsByTagName("vII")[0].InnerText; if (nodo2.GetElementsByTagName("vIOF")[0] != null) ii.vIOF = nodo2.GetElementsByTagName("vIOF")[0].InnerText; } _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = new object(); _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = ii; contador1++; } #endregion det.imposto.II #region det.imposto.ipi if (nodo1.GetElementsByTagName("IPI")[0] != null) { WinUi.Classes.PROCNFE310.TIpi ipi = new WinUi.Classes.PROCNFE310.TIpi(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("IPI"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("clEnq")[0] != null) ipi.clEnq = nodo2.GetElementsByTagName("clEnq")[0].InnerText; if (nodo2.GetElementsByTagName("CNPJProd")[0] != null) ipi.CNPJProd = nodo2.GetElementsByTagName("CNPJProd")[0].InnerText; if (nodo2.GetElementsByTagName("cSelo")[0] != null) ipi.cSelo = nodo2.GetElementsByTagName("cSelo")[0].InnerText; if (nodo2.GetElementsByTagName("qSelo")[0] != null) ipi.qSelo = nodo2.GetElementsByTagName("qSelo")[0].InnerText; if (nodo2.GetElementsByTagName("cEnq")[0] != null) ipi.cEnq = nodo2.GetElementsByTagName("cEnq")[0].InnerText; if ((nodo2.GetElementsByTagName("IPINT")[0] != null) || nodo2.GetElementsByTagName("IPITrib")[0] != null) ipi.Item = new object(); { if (nodo2.GetElementsByTagName("IPINT")[0] != null) ipi.Item = nodo2.GetElementsByTagName("IPINT")[0].InnerText; if (nodo2.GetElementsByTagName("IPITrib")[0] != null) ipi.Item = nodo2.GetElementsByTagName("IPITrib")[0].InnerText; } } _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = new object(); _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = ipi; contador1++; } #endregion det.imposto.ipi #region det.imposto.ISSQN if (nodo1.GetElementsByTagName("ISSQN")[0] != null) { WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoISSQN issQn = new WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoISSQN(); infNFe_det_Imposto_Items = ((XmlElement)nodo1).GetElementsByTagName("ISSQN"); foreach (XmlElement nodo2 in infNFe_det_Imposto_Items) { if (nodo2.GetElementsByTagName("vBC")[0] != null) issQn.vBC = nodo2.GetElementsByTagName("vBC")[0].InnerText; if (nodo2.GetElementsByTagName("vAliq")[0] != null) issQn.vAliq = nodo2.GetElementsByTagName("vAliq")[0].InnerText; if (nodo2.GetElementsByTagName("vISSQN")[0] != null) issQn.vISSQN = nodo2.GetElementsByTagName("vISSQN")[0].InnerText; if (nodo2.GetElementsByTagName("cMunFG")[0] != null) issQn.cMunFG = nodo2.GetElementsByTagName("cMunFG")[0].InnerText; if (nodo2.GetElementsByTagName("cListServ")[0] != null) issQn.cListServ = (WinUi.Classes.PROCNFE310.TCListServ) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TCListServ), nodo2.GetElementsByTagName("cListServ")[0].InnerText); if (nodo2.GetElementsByTagName("vDeducao")[0] != null) issQn.vDeducao = nodo2.GetElementsByTagName("vDeducao")[0].InnerText; if (nodo2.GetElementsByTagName("vOutro")[0] != null) issQn.vOutro = nodo2.GetElementsByTagName("vOutro")[0].InnerText; if (nodo2.GetElementsByTagName("vDescIncond")[0] != null) issQn.vDescIncond = nodo2.GetElementsByTagName("vDescIncond")[0].InnerText; if (nodo2.GetElementsByTagName("vDescCond")[0] != null) issQn.vDescCond = nodo2.GetElementsByTagName("vDescCond")[0].InnerText; if (nodo2.GetElementsByTagName("vISSRet")[0] != null) issQn.vISSRet = nodo2.GetElementsByTagName("vISSRet")[0].InnerText; if (nodo2.GetElementsByTagName("cMunFG")[0] != null) issQn.cMunFG = nodo2.GetElementsByTagName("cMunFG")[0].InnerText; if (nodo2.GetElementsByTagName("indISS")[0] != null) issQn.indISS = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoISSQNIndISS) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TCListServ), nodo2.GetElementsByTagName("indISS")[0].InnerText); if (nodo2.GetElementsByTagName("cServico")[0] != null) issQn.cServico = nodo2.GetElementsByTagName("cServico")[0].InnerText; if (nodo2.GetElementsByTagName("cMun")[0] != null) issQn.cMun = nodo2.GetElementsByTagName("cMun")[0].InnerText; if (nodo2.GetElementsByTagName("cPais")[0] != null) { issQn.cPais = (WinUi.Classes.PROCNFE310.Tpais)Enum.Parse(typeof(WinUi.Classes.PROCNFE310.Tpais), nodo2.GetElementsByTagName("cPais")[0].InnerText); issQn.cPaisSpecified = true; } if (nodo2.GetElementsByTagName("nProcesso")[0] != null) issQn.nProcesso = nodo2.GetElementsByTagName("nProcesso")[0].InnerText; if (nodo2.GetElementsByTagName("nProcesso")[0] != null) issQn.nProcesso = nodo2.GetElementsByTagName("nProcesso")[0].InnerText; if (nodo2.GetElementsByTagName("indIncentivo")[0] != null) issQn.indIncentivo = (WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoISSQNIndIncentivo) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeDetImpostoISSQNIndIncentivo), nodo2.GetElementsByTagName("indIncentivo")[0].InnerText); } _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = new object(); _TNfeProc.NFe.infNFe.det[contador].imposto.Items[contador1] = issQn; contador1++; } #endregion det.imposto.ISSQN //contador1++; #endregion NFE.DET.IMPOSTO } contador++; #endregion NFE.DET } } foreach (XmlElement nodo in infNFe_total) { #region NFE.total _TNfeProc.NFe.infNFe.total = new WinUi.Classes.PROCNFE310.TNFeInfNFeTotal(); if (nodo.GetElementsByTagName("ICMSTot")[0] != null) { _TNfeProc.NFe.infNFe.total.ICMSTot = new WinUi.Classes.PROCNFE310.TNFeInfNFeTotalICMSTot(); if (nodo.GetElementsByTagName("vBC")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vBC = nodo.GetElementsByTagName("vBC")[0].InnerText; if (nodo.GetElementsByTagName("vICMS")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vICMS = nodo.GetElementsByTagName("vICMS")[0].InnerText; if (nodo.GetElementsByTagName("vICMSDeson")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vICMSDeson = nodo.GetElementsByTagName("vICMSDeson")[0].InnerText; if (nodo.GetElementsByTagName("vBCST")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vBCST = nodo.GetElementsByTagName("vBCST")[0].InnerText; if (nodo.GetElementsByTagName("vST")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vST = nodo.GetElementsByTagName("vST")[0].InnerText; if (nodo.GetElementsByTagName("vProd")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vProd = nodo.GetElementsByTagName("vProd")[0].InnerText; if (nodo.GetElementsByTagName("vFrete")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vFrete = nodo.GetElementsByTagName("vFrete")[0].InnerText; if (nodo.GetElementsByTagName("vSeg")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vSeg = nodo.GetElementsByTagName("vSeg")[0].InnerText; if (nodo.GetElementsByTagName("vDesc")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vDesc = nodo.GetElementsByTagName("vDesc")[0].InnerText; if (nodo.GetElementsByTagName("vII")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vII = nodo.GetElementsByTagName("vII")[0].InnerText; if (nodo.GetElementsByTagName("vIPI")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vIPI = nodo.GetElementsByTagName("vIPI")[0].InnerText; if (nodo.GetElementsByTagName("vPIS")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vPIS = nodo.GetElementsByTagName("vPIS")[0].InnerText; if (nodo.GetElementsByTagName("vCOFINS")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vCOFINS = nodo.GetElementsByTagName("vCOFINS")[0].InnerText; if (nodo.GetElementsByTagName("vOutro")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vOutro = nodo.GetElementsByTagName("vOutro")[0].InnerText; if (nodo.GetElementsByTagName("vNF")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vNF = nodo.GetElementsByTagName("vNF")[0].InnerText; if (nodo.GetElementsByTagName("vTotTrib")[0] != null) _TNfeProc.NFe.infNFe.total.ICMSTot.vTotTrib = nodo.GetElementsByTagName("vTotTrib")[0].InnerText; } if (!ehCartaCorrecao) { #region ISSQNtot if (nodo.GetElementsByTagName("ISSQNtot")[0] != null) { _TNfeProc.NFe.infNFe.total.ISSQNtot = new WinUi.Classes.PROCNFE310.TNFeInfNFeTotalISSQNtot(); if (nodo.GetElementsByTagName("vServ")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vServ = nodo.GetElementsByTagName("vServ")[0].InnerText; if (nodo.GetElementsByTagName("vBC")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vBC = nodo.GetElementsByTagName("vBC")[0].InnerText; if (nodo.GetElementsByTagName("vISS")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vISS = nodo.GetElementsByTagName("vISS")[0].InnerText; if (nodo.GetElementsByTagName("vPIS")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vPIS = nodo.GetElementsByTagName("vPIS")[0].InnerText; if (nodo.GetElementsByTagName("vCOFINS")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vCOFINS = nodo.GetElementsByTagName("vCOFINS")[0].InnerText; if (nodo.GetElementsByTagName("dCompet")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.dCompet = nodo.GetElementsByTagName("dCompet")[0].InnerText; if (nodo.GetElementsByTagName("vDeducao")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vDeducao = nodo.GetElementsByTagName("vDeducao")[0].InnerText; if (nodo.GetElementsByTagName("vOutro")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vOutro = nodo.GetElementsByTagName("vOutro")[0].InnerText; if (nodo.GetElementsByTagName("vDescIncond")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vDescIncond = nodo.GetElementsByTagName("vDescIncond")[0].InnerText; if (nodo.GetElementsByTagName("vDescCond")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vDescCond = nodo.GetElementsByTagName("vDescCond")[0].InnerText; if (nodo.GetElementsByTagName("vISSRet")[0] != null) _TNfeProc.NFe.infNFe.total.ISSQNtot.vISSRet = nodo.GetElementsByTagName("vISSRet")[0].InnerText; if (nodo.GetElementsByTagName("cRegTrib")[0] != null) { _TNfeProc.NFe.infNFe.total.ISSQNtot.cRegTrib = (WinUi.Classes.PROCNFE310.TNFeInfNFeTotalISSQNtotCRegTrib) Enum.Parse(typeof(WinUi.Classes.PROCNFE310.TNFeInfNFeTotalISSQNtotCRegTrib), nodo.GetElementsByTagName("cRegTrib")[0].InnerText); _TNfeProc.NFe.infNFe.total.ISSQNtot.cRegTribSpecified = true; } } #endregion ISSQNtot #region retTrib if (nodo.GetElementsByTagName("retTrib")[0] != null) { _TNfeProc.NFe.infNFe.total.retTrib = new WinUi.Classes.PROCNFE310.TNFeInfNFeTotalRetTrib(); if (nodo.GetElementsByTagName("vRetPIS")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vRetPIS = nodo.GetElementsByTagName("vRetPIS")[0].InnerText; if (nodo.GetElementsByTagName("vRetCOFINS")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vRetCOFINS = nodo.GetElementsByTagName("vRetCOFINS")[0].InnerText; if (nodo.GetElementsByTagName("vRetCSLL")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vRetCSLL = nodo.GetElementsByTagName("vRetCSLL")[0].InnerText; if (nodo.GetElementsByTagName("vBCIRRF")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vBCIRRF = nodo.GetElementsByTagName("vBCIRRF")[0].InnerText; if (nodo.GetElementsByTagName("vIRRF")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vIRRF = nodo.GetElementsByTagName("vIRRF")[0].InnerText; if (nodo.GetElementsByTagName("vBCRetPrev")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vBCRetPrev = nodo.GetElementsByTagName("vBCRetPrev")[0].InnerText; if (nodo.GetElementsByTagName("vRetPrev")[0] != null) _TNfeProc.NFe.infNFe.total.retTrib.vRetPrev = nodo.GetElementsByTagName("vRetPrev")[0].InnerText; } #endregion retTrib } #endregion NFE.total }
espero que te ajude
-
Obrigado por tentar me ajudar, mas a maneira que eu to tentando usar é feito de maneira diferente. Acho ela mais prática. Veja como é feito a leitura dos impostos.
dgv_Produtos_NotaFiscal.Rows.Add();
dgv_Produtos_NotaFiscal.Rows[i].Cells[0].Value = nota.NFe.infNFe.det[i].produto.cProd;
dgv_Produtos_NotaFiscal.Rows[i].Cells[1].Value = nota.NFe.infNFe.det[i].produto.xProd;
//
// ICMs situação 00
if (nota.NFe.infNFe.det[i].imposto.ICMS.ICMS00 != null)
{
dgv_Produtos_NotaFiscal.Rows[i].Cells[2].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS00.CST;
dgv_Produtos_NotaFiscal.Rows[i].Cells[3].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS00.vBC;
dgv_Produtos_NotaFiscal.Rows[i].Cells[4].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS00.vICMS;
dgv_Produtos_NotaFiscal.Rows[i].Cells[7].Value = nota.NFe.infNFe.det[i].nItem;
}
else if (nota.NFe.infNFe.det[i].imposto.ICMS.ICMS20 != null) // Icms situaçaão 020
{
dgv_Produtos_NotaFiscal.Rows[i].Cells[2].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS20.CST;
dgv_Produtos_NotaFiscal.Rows[i].Cells[3].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS20.vBC;
dgv_Produtos_NotaFiscal.Rows[i].Cells[4].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS20.vICMS;
dgv_Produtos_NotaFiscal.Rows[i].Cells[5].Value = nota.NFe.infNFe.det[i].imposto.ICMS.ICMS20.pRedBC;
dgv_Produtos_NotaFiscal.Rows[i].Cells[7].Value = nota.NFe.infNFe.det[i].nItem;
}Já tudo dentro dentro do ojbeto nota.