none
Remover um nó xml com C# RRS feed

  • Pergunta

  • Boa tarde!!!

    Alguem poderia me ajudar a remover um nó do xml, o xml é de uma NFe e preciso remover esse nó para integrar o xml no sistema!

    Eu preciso excluir o Nó <rastro></rastro> preciso excluir todo conteudo e as tags.

    Segue dados do XML.

    <det nItem="1">
    <prod>
    <cProd>000000000000002264</cProd>
    <cEAN>7891330014897</cEAN>
    <xProd>BARRA 70G STIKADINHO 4X840G (12X70G)</xProd>
    <NCM>18063110</NCM>
    <CEST>1700200</CEST>
    <CFOP>5401</CFOP>
    <uCom>CX</uCom>
    <qCom>1.0000</qCom>
    <vUnCom>78.9500000000</vUnCom>
    <vProd>78.95</vProd>
    <cEANTrib>7891330014897</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>1.0000</qTrib>
    <vUnTrib>78.9500000000</vUnTrib>
    <indTot>1</indTot>
    <nFCI>6641CCE1-5DDE-4876-BDDE-6A8B226C361C</nFCI>
    <rastro>
    <nLote>0000053372</nLote>
    <qLote>1.000</qLote>
    <dFab>2018-03-12</dFab>
    <dVal>2019-03-12</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS10>
    <orig>5</orig>
    <CST>10</CST>
    <modBC>3</modBC>
    <vBC>78.95</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>14.21</vICMS>
    <modBCST>4</modBCST>
    <vBCST>144.14</vBCST>
    <pICMSST>18.0000</pICMSST>
    <vICMSST>11.73</vICMSST>
    </ICMS10>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>78.95</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>3.95</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>1.30</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>6.00</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 1,30 COFINS: 6,00</infAdProd>
    </det>

    domingo, 1 de abril de 2018 20:28

Respostas

  • Bom dia amigo,

    Assim funcionou:

              string xml = File.ReadAllText(@"C:\Users\edson\Desktop\remover_no\Novo Documento de Texto.xml");
                XmlDocument doc = new XmlDocument();
                doc.Load(@"C:\Users\edson\Desktop\remover_no\Novo Documento de Texto.xml");
    
                while (doc.GetElementsByTagName("rastro").Count > 0)
                {
                    var xml_node = doc.GetElementsByTagName("rastro")[0];
                    xml_node.ParentNode.RemoveChild(xml_node);
                }
         
                string xml_new = doc.OuterXml;

    Espero ter ajudado!

    Abraço!

    • Marcado como Resposta Willians Junior quarta-feira, 4 de abril de 2018 13:59
    quarta-feira, 4 de abril de 2018 13:01

Todas as Respostas

  • Bom dia Lucio,

    Não deu certo.... mas valeu pela dica

    segunda-feira, 2 de abril de 2018 11:52
  • Olá bom dia,

    Tente assim:

                XmlDocument doc = new XmlDocument();
                doc.Load(@"SEU_CAMINHO");
                XmlNode node = doc.SelectSingleNode("/det/prod/rastro");
                node.ParentNode.RemoveChild(node);
                string xml_new = doc.OuterXml;

    Espero ter ajudado!

    Abraço!


    segunda-feira, 2 de abril de 2018 12:51
  • Boa tarde EDson, da um erro de referencia de objeto.
    segunda-feira, 2 de abril de 2018 15:27
  • Tentei tb... da o mesmo erro!
    segunda-feira, 2 de abril de 2018 15:47
  • Coloque aqui o seu código, para verificarmos.

    Abraço!


    • Editado Edson Loris segunda-feira, 2 de abril de 2018 17:24
    segunda-feira, 2 de abril de 2018 17:24
  •  private void button1_Click(object sender, EventArgs e)
            {
                foreach (string xml in lbxXmls.Items)
                {
                    XmlDocument neuge = new XmlDocument();
                    neuge.Load(xml);
                    XmlNode node = neuge.SelectSingleNode("/det/prod/rastro");
                    neuge.ParentNode.RemoveChild(node);

                    neuge.Save(xml);

                }

            }
    segunda-feira, 2 de abril de 2018 17:34
  •  private void button1_Click(object sender, EventArgs e)
            {
                foreach (string xml in lbxXmls.Items)
                {
                    XmlDocument neuge = new XmlDocument();
                    neuge.Load(xml);
                    XmlNode node = neuge.SelectSingleNode("/det/prod/rastro");
                    neuge.ParentNode.RemoveChild(node);

                    neuge.Save(xml);

                }

            }

    O Correto seria:

         private void button1_Click(object sender, EventArgs e)
            {
                foreach (string xml in lbxXmls.Items)
                {
    
                    XmlDocument neuge = new XmlDocument();
                    neuge.Load(xml);//verifique está linha
                    XmlNode node = neuge.SelectSingleNode("/det/prod/rastro");
                    node.ParentNode.RemoveChild(node);
                    neuge.Save(xml);
    
                }
    
            }

    Verifique se o caminho do XML está correto.

    Fiz o teste local com o xml do primeiro post e com este algoritmo acima, funcionou perfeitamente! 

    Um abraço!


    • Editado Edson Loris segunda-feira, 2 de abril de 2018 17:45
    segunda-feira, 2 de abril de 2018 17:44
  • Fiz dessa forma:

               

     XmlDocument neuge = new XmlDocument();
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    neuge.Load(openFileDialog1.FileName);
                    XmlNode node = neuge.SelectSingleNode(@"det");
                    node.ParentNode.RemoveChild(node);
                    neuge.Save(SaveFileDialog1.fileName);
                }
     Fiz dessa forma:

                                        XmlDocument neuge = new XmlDocument();

                    neuge.Load(@"c:\");
                    XmlNode node = neuge.SelectSingleNode(@"det");
                    node.ParentNode.RemoveChild(node);
                    neuge.Save(@"c:\");

    e da erro nessa Linha: node.ParentNode.RemoveChild(node);


    segunda-feira, 2 de abril de 2018 18:27
  • O Problema está nestas linhas:

     neuge.Load(@"c:\");

    Tem que ser o caminho completo do arquivo:

    neuge.Load(@"c:\arquivo.xml");

    Outra coisa coloque assim:

    XmlNode node = neuge.SelectSingleNode("/det/prod/rastro");

    Abraço!



    • Editado Edson Loris segunda-feira, 2 de abril de 2018 18:43
    segunda-feira, 2 de abril de 2018 18:42
  • Veja se esse artigo pode te ajudar.

    https://ecode10.com/artigo/794/Cortando-String-XML


    Espero ter ajudado. Se ajudei, favor marcar no fórum falando que foi útil.

    Mauricio Junior - Comunidade www.ecode10.com

    segunda-feira, 2 de abril de 2018 21:52
  • Edson, realmente o seu codigo funcionou.... estava dando erro pelo seguinte o xml que postei é só um trecho do xml, digamos a parte importante o xml completo é de uma NFe, por isso que apresentava o erro de referencia do objeto. Fiz o teste do seu algoritmo com o primeiro trecho do xml e funcionou perfeitamente, porem no xml completo não funciona. Tentei usar a mesma logica do seu algoritmo incluindo todos os nós que vem antes do Rastro mas não deu... Desculpa a falha na informação kkkkk.... segue o xml completo. Desde já obrigado!

    <nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
    <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <infNFe versao="4.00" Id="NFe35180387315834001146550010000111831860713740">
    <ide>...</ide>
    <emit>...</emit>
    <dest>...</dest>
    <det nItem="1">
    <prod>
    <cProd>000000000000002264</cProd>
    <cEAN>7891330014897</cEAN>
    <xProd>BARRA 70G STIKADINHO 4X840G (12X70G)</xProd>
    <NCM>18063110</NCM>
    <CEST>1700200</CEST>
    <CFOP>5401</CFOP>
    <uCom>CX</uCom>
    <qCom>1.0000</qCom>
    <vUnCom>78.9500000000</vUnCom>
    <vProd>78.95</vProd>
    <cEANTrib>7891330014897</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>1.0000</qTrib>
    <vUnTrib>78.9500000000</vUnTrib>
    <indTot>1</indTot>
    <nFCI>6641CCE1-5DDE-4876-BDDE-6A8B226C361C</nFCI>
    <rastro>
    <nLote>0000053372</nLote>
    <qLote>1.000</qLote>
    <dFab>2018-03-12</dFab>
    <dVal>2019-03-12</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS10>
    <orig>5</orig>
    <CST>10</CST>
    <modBC>3</modBC>
    <vBC>78.95</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>14.21</vICMS>
    <modBCST>4</modBCST>
    <vBCST>144.14</vBCST>
    <pICMSST>18.0000</pICMSST>
    <vICMSST>11.73</vICMSST>
    </ICMS10>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>78.95</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>3.95</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>1.30</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>6.00</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 1,30 COFINS: 6,00</infAdProd>
    </det>
    <det nItem="2">
    <prod>
    <cProd>000000000000002683</cProd>
    <cEAN>7898423411113</cEAN>
    <xProd>PB AMOR AMOR MACA NEUGE 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5101</CFOP>
    <uCom>CX</uCom>
    <qCom>10.0000</qCom>
    <vUnCom>55.2070000000</vUnCom>
    <vProd>552.07</vProd>
    <cEANTrib>7898423411113</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>10.0000</qTrib>
    <vUnTrib>55.2070000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000052461</nLote>
    <qLote>10.000</qLote>
    <dFab>2018-02-08</dFab>
    <dVal>2020-02-08</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>552.07</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>99.37</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>552.07</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>27.60</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>9.11</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>41.96</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 9,11 COFINS: 41,96</infAdProd>
    </det>
    <det nItem="3">
    <prod>
    <cProd>000000000000002684</cProd>
    <cEAN>7898423411151</cEAN>
    <xProd>PB AMOR AMOR MACA VERDE NEUG 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5101</CFOP>
    <uCom>CX</uCom>
    <qCom>10.0000</qCom>
    <vUnCom>55.2070000000</vUnCom>
    <vProd>552.07</vProd>
    <cEANTrib>7898423411151</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>10.0000</qTrib>
    <vUnTrib>55.2070000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000051691</nLote>
    <qLote>10.000</qLote>
    <dFab>2018-01-11</dFab>
    <dVal>2020-01-11</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>552.07</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>99.37</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>552.07</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>27.60</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>9.11</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>41.96</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 9,11 COFINS: 41,96</infAdProd>
    </det>
    <det nItem="4">
    <prod>
    <cProd>000000000000002685</cProd>
    <cEAN>7898423411144</cEAN>
    <xProd>PB AMOR AMOR UVA NEUGE 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5102</CFOP>
    <uCom>CX</uCom>
    <qCom>5.0000</qCom>
    <vUnCom>55.2060000000</vUnCom>
    <vProd>276.03</vProd>
    <cEANTrib>7898423411144</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>5.0000</qTrib>
    <vUnTrib>55.2060000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000052440</nLote>
    <qLote>5.000</qLote>
    <dFab>2018-02-06</dFab>
    <dVal>2020-02-06</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>276.03</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>49.69</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>276.03</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>13.80</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>276.03</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>4.55</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>276.03</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>20.98</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 4,55 COFINS: 20,98</infAdProd>
    </det>
    <det nItem="5">
    <prod>
    <cProd>000000000000002846</cProd>
    <cEAN>7891330016532</cEAN>
    <xProd>STIKADINHO MORANGO 20X394G (32X12,3G)</xProd>
    <NCM>18063110</NCM>
    <CEST>1700200</CEST>
    <CFOP>5401</CFOP>
    <uCom>CX</uCom>
    <qCom>5.0000</qCom>
    <vUnCom>132.2180000000</vUnCom>
    <vProd>661.09</vProd>
    <cEANTrib>7891330016532</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>5.0000</qTrib>
    <vUnTrib>132.2180000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000053336</nLote>
    <qLote>5.000</qLote>
    <dFab>2018-03-09</dFab>
    <dVal>2019-03-09</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS10>
    <orig>0</orig>
    <CST>10</CST>
    <modBC>3</modBC>
    <vBC>661.09</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>119.00</vICMS>
    <modBCST>4</modBCST>
    <vBCST>1206.98</vBCST>
    <pICMSST>18.0000</pICMSST>
    <vICMSST>98.26</vICMSST>
    </ICMS10>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>661.09</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>33.05</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>661.09</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>10.91</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>661.09</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>50.24</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 10,91 COFINS: 50,24</infAdProd>
    </det>
    <total>
    <ICMSTot>
    <vBC>2120.21</vBC>
    <vICMS>381.64</vICMS>
    <vICMSDeson>0.00</vICMSDeson>
    <vFCP>0.00</vFCP>
    <vBCST>1351.12</vBCST>
    <vST>109.99</vST>
    <vFCPST>0.00</vFCPST>
    <vFCPSTRet>0.00</vFCPSTRet>
    <vProd>2120.21</vProd>
    <vFrete>0.00</vFrete>
    <vSeg>0.00</vSeg>
    <vDesc>0.00</vDesc>
    <vII>0.00</vII>
    <vIPI>106.00</vIPI>
    <vIPIDevol>0.00</vIPIDevol>
    <vPIS>34.98</vPIS>
    <vCOFINS>161.14</vCOFINS>
    <vOutro>0.00</vOutro>
    <vNF>2336.20</vNF>
    </ICMSTot>
    </total>
    <transp>
    <modFrete>0</modFrete>
    <transporta>
    <CNPJ>67199737000156</CNPJ>
    <xNome>TAFF TRANSP ROD EIRELI</xNome>
    <IE>206404772110</IE>
    <xEnder>AV PREFEITO JOAO VILALLOBO QU 1505B</xEnder>
    <xMun>BARUERI</xMun>
    <UF>SP</UF>
    </transporta>
    <vol>
    <qVol>31</qVol>
    <esp>CX</esp>
    <pesoL>234.760</pesoL>
    <pesoB>260.120</pesoB>
    </vol>
    </transp>
    <pag>
    <detPag>
    <tPag>99</tPag>
    <vPag>2336.20</vPag>
    </detPag>
    </pag>
    <infAdic>
    <infCpl>
    Representante:0000031530-BEIRO & BEIRO REP COM PROD HIG LIM
    </infCpl>
    </infAdic>
    </infNFe>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
    <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
    <Reference URI="#NFe35180387315834001146550010000111831860713740">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
    <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <DigestValue>Ele9Ih/AyP/1NW8ot36L6JuKXgk=</DigestValue>
    </Reference>
    </SignedInfo>
    <SignatureValue>
    APkn1Ra+tdHZgWyhoiHMqfgbJvsV31O+JuezHDVqvVa2UztcV/CfkODW94slZXINKwgVbEeyHHSd roAccetwa0go5UBaorpa/HpalVAgn4jH13BO87hIKPtcBlwAIH+iWTdZN3RTKvuiJ752mZCs+QlU XYCmU/c7xBEOXPmMuyEJ9ypkxB+8SXBO9G7Ijkpuho/Ocr8V5GalTFBrbjl260MViarF4aaaFLgI BrkzH4tXv0bWYwsIn2sESFUQPQroyt4iK8fYj+lpplij7RiZjWs3MLAwIPFn5nTFxh+KjPljbx+Y V5LIHcA9vW+mpxfrnRSSr3d5z1MxCKavsZRPtg==
    </SignatureValue>
    <KeyInfo>
    <X509Data>
    <X509Certificate>
    MIIH4TCCBcmgAwIBAgIQArJwNY7Ouh8+dez6MP1BUTANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQG EwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDEtMCsGA1UECxMkQ2VydGlzaWduIENlcnRpZmljYWRv cmEgRGlnaXRhbCBTLkEuMSEwHwYDVQQDExhBQyBDZXJ0aXNpZ24gTXVsdGlwbGEgRzcwHhcNMTcw OTI4MTUwNzI4WhcNMTgwOTI4MTUwNzI4WjCBrjELMAkGA1UEBhMCQlIxEzARBgNVBAoMCklDUC1C cmFzaWwxJjAkBgNVBAsMHUF1dGVudGljYWRvIHBvciBBUiBCREkgQnJhc2lsMRswGQYDVQQLDBJB c3NpbmF0dXJhIFRpcG8gQTExHDAaBgNVBAMME1ZPTlBBUiBBTElNRU5UT1MgU0ExJzAlBgkqhkiG 9w0BCQEWGHZ3ZWlzc0BuZXVnZWJhdWVyLmNvbS5icjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC AQoCggEBAL2gKESAh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+w1aEN/PUfOqryX0z4U/7RHV4=
    </X509Certificate>
    </X509Data>
    </KeyInfo>
    </Signature>
    </NFe>
    <protNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
    <infProt>
    <tpAmb>1</tpAmb>
    <verAplic>SP_NFE_PL009_V4</verAplic>
    <chNFe>35180387315834001146550010000111831860713740</chNFe>
    <dhRecbto>2018-03-29T09:40:24-03:00</dhRecbto>
    <nProt>135180212437808</nProt>
    <digVal>Ele9Ih/AyP/1NW8ot36L6JuKXgk=</digVal>
    <cStat>100</cStat>
    <xMotivo>Autorizado o uso da NF-e</xMotivo>
    </infProt>
    </protNFe>
    </nfeProc>

    terça-feira, 3 de abril de 2018 00:02
  • Edson, realmente o seu codigo funcionou.... estava dando erro pelo seguinte o xml que postei é só um trecho do xml, digamos a parte importante o xml completo é de uma NFe, por isso que apresentava o erro de referencia do objeto. Fiz o teste do seu algoritmo com o primeiro trecho do xml e funcionou perfeitamente, porem no xml completo não funciona. Tentei usar a mesma logica do seu algoritmo incluindo todos os nós que vem antes do Rastro mas não deu... Desculpa a falha na informação kkkkk.... segue o xml completo. Desde já obrigado!
    <nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
    <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <infNFe versao="4.00" Id="NFe35180387315834001146550010000111831860713740">
    <ide>...</ide>
    <emit>...</emit>
    <dest>...</dest>
    <det nItem="1">
    <prod>
    <cProd>000000000000002264</cProd>
    <cEAN>7891330014897</cEAN>
    <xProd>BARRA 70G STIKADINHO 4X840G (12X70G)</xProd>
    <NCM>18063110</NCM>
    <CEST>1700200</CEST>
    <CFOP>5401</CFOP>
    <uCom>CX</uCom>
    <qCom>1.0000</qCom>
    <vUnCom>78.9500000000</vUnCom>
    <vProd>78.95</vProd>
    <cEANTrib>7891330014897</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>1.0000</qTrib>
    <vUnTrib>78.9500000000</vUnTrib>
    <indTot>1</indTot>
    <nFCI>6641CCE1-5DDE-4876-BDDE-6A8B226C361C</nFCI>
    <rastro>
    <nLote>0000053372</nLote>
    <qLote>1.000</qLote>
    <dFab>2018-03-12</dFab>
    <dVal>2019-03-12</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS10>
    <orig>5</orig>
    <CST>10</CST>
    <modBC>3</modBC>
    <vBC>78.95</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>14.21</vICMS>
    <modBCST>4</modBCST>
    <vBCST>144.14</vBCST>
    <pICMSST>18.0000</pICMSST>
    <vICMSST>11.73</vICMSST>
    </ICMS10>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>78.95</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>3.95</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>1.30</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>78.95</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>6.00</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 1,30 COFINS: 6,00</infAdProd>
    </det>
    <det nItem="2">
    <prod>
    <cProd>000000000000002683</cProd>
    <cEAN>7898423411113</cEAN>
    <xProd>PB AMOR AMOR MACA NEUGE 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5101</CFOP>
    <uCom>CX</uCom>
    <qCom>10.0000</qCom>
    <vUnCom>55.2070000000</vUnCom>
    <vProd>552.07</vProd>
    <cEANTrib>7898423411113</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>10.0000</qTrib>
    <vUnTrib>55.2070000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000052461</nLote>
    <qLote>10.000</qLote>
    <dFab>2018-02-08</dFab>
    <dVal>2020-02-08</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>552.07</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>99.37</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>552.07</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>27.60</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>9.11</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>41.96</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 9,11 COFINS: 41,96</infAdProd>
    </det>
    <det nItem="3">
    <prod>
    <cProd>000000000000002684</cProd>
    <cEAN>7898423411151</cEAN>
    <xProd>PB AMOR AMOR MACA VERDE NEUG 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5101</CFOP>
    <uCom>CX</uCom>
    <qCom>10.0000</qCom>
    <vUnCom>55.2070000000</vUnCom>
    <vProd>552.07</vProd>
    <cEANTrib>7898423411151</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>10.0000</qTrib>
    <vUnTrib>55.2070000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000051691</nLote>
    <qLote>10.000</qLote>
    <dFab>2018-01-11</dFab>
    <dVal>2020-01-11</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>552.07</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>99.37</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>552.07</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>27.60</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>9.11</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>552.07</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>41.96</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 9,11 COFINS: 41,96</infAdProd>
    </det>
    <det nItem="4">
    <prod>
    <cProd>000000000000002685</cProd>
    <cEAN>7898423411144</cEAN>
    <xProd>PB AMOR AMOR UVA NEUGE 16X480G 20G</xProd>
    <NCM>17049020</NCM>
    <CFOP>5102</CFOP>
    <uCom>CX</uCom>
    <qCom>5.0000</qCom>
    <vUnCom>55.2060000000</vUnCom>
    <vProd>276.03</vProd>
    <cEANTrib>7898423411144</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>5.0000</qTrib>
    <vUnTrib>55.2060000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000052440</nLote>
    <qLote>5.000</qLote>
    <dFab>2018-02-06</dFab>
    <dVal>2020-02-06</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS00>
    <orig>0</orig>
    <CST>00</CST>
    <modBC>3</modBC>
    <vBC>276.03</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>49.69</vICMS>
    </ICMS00>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>276.03</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>13.80</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>276.03</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>4.55</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>276.03</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>20.98</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 4,55 COFINS: 20,98</infAdProd>
    </det>
    <det nItem="5">
    <prod>
    <cProd>000000000000002846</cProd>
    <cEAN>7891330016532</cEAN>
    <xProd>STIKADINHO MORANGO 20X394G (32X12,3G)</xProd>
    <NCM>18063110</NCM>
    <CEST>1700200</CEST>
    <CFOP>5401</CFOP>
    <uCom>CX</uCom>
    <qCom>5.0000</qCom>
    <vUnCom>132.2180000000</vUnCom>
    <vProd>661.09</vProd>
    <cEANTrib>7891330016532</cEANTrib>
    <uTrib>DP</uTrib>
    <qTrib>5.0000</qTrib>
    <vUnTrib>132.2180000000</vUnTrib>
    <indTot>1</indTot>
    <rastro>
    <nLote>0000053336</nLote>
    <qLote>5.000</qLote>
    <dFab>2018-03-09</dFab>
    <dVal>2019-03-09</dVal>
    <cAgreg>00000000000000000000</cAgreg>
    </rastro>
    </prod>
    <imposto>
    <ICMS>
    <ICMS10>
    <orig>0</orig>
    <CST>10</CST>
    <modBC>3</modBC>
    <vBC>661.09</vBC>
    <pICMS>18.0000</pICMS>
    <vICMS>119.00</vICMS>
    <modBCST>4</modBCST>
    <vBCST>1206.98</vBCST>
    <pICMSST>18.0000</pICMSST>
    <vICMSST>98.26</vICMSST>
    </ICMS10>
    </ICMS>
    <IPI>
    <qSelo>000000000000</qSelo>
    <cEnq>999</cEnq>
    <IPITrib>
    <CST>50</CST>
    <vBC>661.09</vBC>
    <pIPI>5.0000</pIPI>
    <vIPI>33.05</vIPI>
    </IPITrib>
    </IPI>
    <PIS>
    <PISAliq>
    <CST>01</CST>
    <vBC>661.09</vBC>
    <pPIS>1.6500</pPIS>
    <vPIS>10.91</vPIS>
    </PISAliq>
    </PIS>
    <COFINS>
    <COFINSAliq>
    <CST>01</CST>
    <vBC>661.09</vBC>
    <pCOFINS>7.6000</pCOFINS>
    <vCOFINS>50.24</vCOFINS>
    </COFINSAliq>
    </COFINS>
    </imposto>
    <infAdProd>PIS: 10,91 COFINS: 50,24</infAdProd>
    </det>
    <total>
    <ICMSTot>
    <vBC>2120.21</vBC>
    <vICMS>381.64</vICMS>
    <vICMSDeson>0.00</vICMSDeson>
    <vFCP>0.00</vFCP>
    <vBCST>1351.12</vBCST>
    <vST>109.99</vST>
    <vFCPST>0.00</vFCPST>
    <vFCPSTRet>0.00</vFCPSTRet>
    <vProd>2120.21</vProd>
    <vFrete>0.00</vFrete>
    <vSeg>0.00</vSeg>
    <vDesc>0.00</vDesc>
    <vII>0.00</vII>
    <vIPI>106.00</vIPI>
    <vIPIDevol>0.00</vIPIDevol>
    <vPIS>34.98</vPIS>
    <vCOFINS>161.14</vCOFINS>
    <vOutro>0.00</vOutro>
    <vNF>2336.20</vNF>
    </ICMSTot>
    </total>
    <transp>
    <modFrete>0</modFrete>
    <transporta>
    <CNPJ>67199737000156</CNPJ>
    <xNome>TAFF TRANSP ROD EIRELI</xNome>
    <IE>206404772110</IE>
    <xEnder>AV PREFEITO JOAO VILALLOBO QU 1505B</xEnder>
    <xMun>BARUERI</xMun>
    <UF>SP</UF>
    </transporta>
    <vol>
    <qVol>31</qVol>
    <esp>CX</esp>
    <pesoL>234.760</pesoL>
    <pesoB>260.120</pesoB>
    </vol>
    </transp>
    <pag>
    <detPag>
    <tPag>99</tPag>
    <vPag>2336.20</vPag>
    </detPag>
    </pag>
    <infAdic>
    <infCpl>
    Representante:0000031530-BEIRO & BEIRO REP COM PROD HIG LIM
    </infCpl>
    </infAdic>
    </infNFe>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
    <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
    <Reference URI="#NFe35180387315834001146550010000111831860713740">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
    <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <DigestValue>Ele9Ih/AyP/1NW8ot36L6JuKXgk=</DigestValue>
    </Reference>
    </SignedInfo>
    <SignatureValue>
    APkn1Ra+tdHZgWyhoiHMqfgbJvsV31O+JuezHDVqvVa2UztcV/CfkODW94slZXINKwgVbEeyHHSd roAccetwa0go5UBaorpa/HpalVAgn4jH13BO87hIKPtcBlwAIH+iWTdZN3RTKvuiJ752mZCs+QlU XYCmU/c7xBEOXPmMuyEJ9ypkxB+8SXBO9G7Ijkpuho/Ocr8V5GalTFBrbjl260MViarF4aaaFLgI BrkzH4tXv0bWYwsIn2sESFUQPQroyt4iK8fYj+lpplij7RiZjWs3MLAwIPFn5nTFxh+KjPljbx+Y V5LIHcA9vW+mpxfrnRSSr3d5z1MxCKavsZRPtg==
    </SignatureValue>
    <KeyInfo>
    <X509Data>
    <X509Certificate>
    MIIH4TCCBcmgAwIBAgIQArJwNY7Ouh8+dez6MP1BUTANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQG EwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDEtMCsGA1UECxMkQ2VydGlzaWduIENlcnRpZmljYWRv cmEgRGlnaXRhbCBTLkEuMSEwHwYDVQQDExhBQyBDZXJ0aXNpZ24gTXVsdGlwbGEgRzcwHhcNMTcw OTI4MTUwNzI4WhcNMTgwOTI4MTUwNzI4WjCBrjELMAkGA1UEBhMCQlIxEzARBgNVBAoMC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Vh7LzXVU/Ez XOto7ZXZK9+k/EF0PeR13e9EcBwqCDXOyrvk/KPoYjs2isZQ8OV7F7CeLRTnZg67lfz81XwxZ4d0 pYzb6zbEd3PysiymBZLQy0fNAeCX1D1D5YxtHzpN4KLWQMdU8hZbweR5gLRxRBuzVgdbDr1FIcrW C7G0mbsFlLBb0r0nWgHe3dFsnT3JBijHhdLGkSfXzuVJrWT71F/A78kCXFIgU1KK1cBj78+6oHVm jpwr95oepA+w1aEN/PUfOqryX0z4U/7RHV4=
    </X509Certificate>
    </X509Data>
    </KeyInfo>
    </Signature>
    </NFe>
    <protNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
    <infProt>
    <tpAmb>1</tpAmb>
    <verAplic>SP_NFE_PL009_V4</verAplic>
    <chNFe>35180387315834001146550010000111831860713740</chNFe>
    <dhRecbto>2018-03-29T09:40:24-03:00</dhRecbto>
    <nProt>135180212437808</nProt>
    <digVal>Ele9Ih/AyP/1NW8ot36L6JuKXgk=</digVal>
    <cStat>100</cStat>
    <xMotivo>Autorizado o uso da NF-e</xMotivo>
    </infProt>
    </protNFe>
    </nfeProc>

    quarta-feira, 4 de abril de 2018 02:01
  • Bom dia amigo,

    Assim funcionou:

              string xml = File.ReadAllText(@"C:\Users\edson\Desktop\remover_no\Novo Documento de Texto.xml");
                XmlDocument doc = new XmlDocument();
                doc.Load(@"C:\Users\edson\Desktop\remover_no\Novo Documento de Texto.xml");
    
                while (doc.GetElementsByTagName("rastro").Count > 0)
                {
                    var xml_node = doc.GetElementsByTagName("rastro")[0];
                    xml_node.ParentNode.RemoveChild(xml_node);
                }
         
                string xml_new = doc.OuterXml;

    Espero ter ajudado!

    Abraço!

    • Marcado como Resposta Willians Junior quarta-feira, 4 de abril de 2018 13:59
    quarta-feira, 4 de abril de 2018 13:01
  • Vlw Edson, muito Obrigado pela ajuda.
    quarta-feira, 4 de abril de 2018 14:00