From 40a6ae9feb13abc812584370c2158dd6dc77a588 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Mon, 22 May 2017 19:05:51 -0300 Subject: [PATCH] =?UTF-8?q?Encontra=20tag=20infNFe=20tamb=C3=A9m=20com=20n?= =?UTF-8?q?amespace,=20como=20padr=C3=A3o=20de=20arquivos=20parseados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/assinatura.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pynfe/processamento/assinatura.py b/pynfe/processamento/assinatura.py index b7d4b5a..2e0472e 100644 --- a/pynfe/processamento/assinatura.py +++ b/pynfe/processamento/assinatura.py @@ -35,7 +35,11 @@ class AssinaturaA1(Assinatura): etree.SubElement(siginfo, 'SignatureMethod', Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1') # Tenta achar a tag infNFe try: - ref = etree.SubElement(siginfo, 'Reference', URI='#'+xml.findall('infNFe')[0].attrib['Id']) + if len(xml.nsmap.items()) == 0: # não tem namespace + ref = etree.SubElement(siginfo, 'Reference', URI='#'+xml.findall('infNFe')[0].attrib['Id']) + else: + ns = {'ns': 'http://www.portalfiscal.inf.br/nfe'} + ref = etree.SubElement(siginfo, 'Reference', URI='#'+xml.findall('ns:infNFe', namespaces=ns)[0].attrib['Id']) # Caso nao tenha a tag infNFe, procura a tag infEvento except IndexError: try: