I'm doing an application that is responsible for separating XML files based on some parameters, that's fine, but now with the changes of the CFDI, my programming thundered, since users can have mixed the documents of cfdi 3.2 and 3.3 in the same folder.
What strikes me the route of the documents is that in version 3.2 I obtained the data in this way:
strVersion = doc.GetElementsByTagName("cfdi:Comprobante")(0).Attributes("version").Value
but now with the change to 3.3 it fails me since the first letter of the attributes was changed to uppercase, and now it would be
strVersion = doc.GetElementsByTagName("cfdi:Comprobante")(0).Attributes("Version").Value
There will be a way that in case the attribute ("version")
does not exist then take the value ("Version")
, or in Attributes
not distinguish between version
and Version
, I hope to understand and can suggest something to me.
Annex the structure of the XML to see if you can recover their values in a different way than what I do.
Version 3.3
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante Certificado="MIQ=" Fecha="2018-02-01T01:56:11" Folio="012180001054132653" FormaPago="03" LugarExpedicion="06600" TipoCambio="1" TipoDeComprobante="I" Total="0000.00" Version="3.3" xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd">
<cfdi:Emisor Nombre="BBVA BANCOMER, S A" RegimenFiscal="w232" Rfc="RFSGEGHSFS"/>
<cfdi:Receptor Nombre="XXXXXXXXXXXXX" Rfc="XXXXXXXXXXXXXXXXXX" UsoCFDI="XXX"/>
</cfdi:Comprobante>
Version 3.2
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd http://www.sat.gob.mx/ine http://www.sat.gob.mx/sitio_internet/cfd/ine/ine11.xsd" version="3.2" serie="TF" sello="J=" noCertificado="00001000000402403936" certificado="MI=" condicionesDePago="PAGO INMEDIATO SIN DESC. POR P" subTotal="0.00" TipoCambio="1.00000" Moneda="MXN" total="0.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cfdi="http://www.sat.gob.mx/cfd/3">
<cfdi:Emisor rfc="RFCGF242FD" nombre="Lorem">
</cfdi:Emisor>
<cfdi:Receptor rfc="EWCVFFSFDF" nombre="Lorem imp">
</cfdi:Receptor>
</cfdi:Comprobante>