Sub listatodoxml2()
Dim oXml As Object 'MSXML2.DOMDocument60
Dim oNodes As IXMLDOMNodeList
Dim oNode As IXMLDOMNode
Dim i As Long
Dim xNodoComprobante 'Para tomar los datos de la Etiqueta Comprobante
Dim xListaNodoComprobante As Object ' nodos
Dim xNodoEmisor 'Para tomar los datos de la Etiqueta Emisor
Dim xListaNodoEmisor As Object ' nodos
Dim xNodoReceptor 'Para tomar los datos de la Etiqueta Emisor
Dim xListaNodoReceptor As Object ' nodos
Dim xNodoImpuestosConcepto 'Para Tomar los Datos de la Etiqueta Impuestos por partida
Dim xListaNodoImpuestosConcepto As Object ' nodos
Dim xNodoImpuestos 'Para Tomar los Datos de la Etiqueta Impuestos Global Factura
Dim xListaNodoImpuestos As Object ' nodos
Dim xNodoComplementoTFD 'Para Tomar los Datos de la Etiqueta Impuestos
Dim xListaNodoComplementoTFD As Object ' nodos
Dim mydb As DAO.Database
Dim rstx As DAO.Recordset
Dim sqlborratbl As String
Dim Count As Integer 'Cuenta Conceptos
Dim CountImp As Integer 'Cuenta Impuestos de Conceptos
sqlborratbl = "delete * from [tblXML]"
CurrentDb.Execute sqlborratbl
Set oXml = CreateObject("MSXML2.DOMDocument") 'New MSXML2.DOMDocument60
With oXml
.Load "C:\........\ejemplocfdi.xml"
Set oNodes = .getElementsByTagName("cfdi:Concepto")
Count = 0
'SelectSingleNode
For Each oNode In oNodes
'Debug.Print oNode.nodeName
Count = Count + 1
'Debug.Print "#### COMIENZA REGISTRO####"
For i = 0 To oNode.Attributes.Length - 1
Debug.Print oNode.Attributes(i).nodeName; Tab(30); _
oNode.Attributes(i).nodeValue
Next i
Set xListaNodoComprobante = oXml.selectNodes("/cfdi:Comprobante")
For Each xNodoComprobante In xListaNodoComprobante
Set xListaNodoEmisor = oXml.selectNodes("/cfdi:Comprobante/cfdi:Emisor")
For Each xNodoEmisor In xListaNodoEmisor
Set xListaNodoReceptor = oXml.selectNodes("/cfdi:Comprobante/cfdi:Receptor")
For Each xNodoReceptor In xListaNodoReceptor
Set xListaNodoImpuestos = oXml.selectNodes("/cfdi:Comprobante/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado")
For Each xNodoImpuestos In xListaNodoImpuestos
Set xListaNodoComplementoTFD = oXml.selectNodes("/cfdi:Comprobante/cfdi:Complemento/tfd:TimbreFiscalDigital")
For Each xNodoComplementoTFD In xListaNodoComplementoTFD
Set mydb = CurrentDb
Set rstx = mydb.OpenRecordset("tblXML")
rstx.AddNew
rstx!Id = Count
rstx!Concepto_ClaveProdServ = oNode.Attributes.getNamedItem("ClaveProdServ").text
rstx!Concepto_Cantidad = oNode.Attributes.getNamedItem("Cantidad").text
rstx!Concepto_ClaveUnidad = oNode.Attributes.getNamedItem("ClaveUnidad").text
rstx!Concepto_Unidad = oNode.Attributes.getNamedItem("Unidad").text
rstx!Concepto_Descripcion = oNode.Attributes.getNamedItem("Descripcion").text
rstx!Concepto_ValorUnitario = oNode.Attributes.getNamedItem("ValorUnitario").text
rstx!Concepto_Importe = oNode.Attributes.getNamedItem("Importe").text
rstx!Comprobante_xmlns_xsi = xNodoComprobante.Attributes.getNamedItem("xmlns:xsi").text
rstx!Comprobante_xsi_schemaLocation = xNodoComprobante.Attributes.getNamedItem("xsi:schemaLocation").text
rstx!Comprobante_LugarExpedicion = xNodoComprobante.Attributes.getNamedItem("LugarExpedicion").text
rstx!Comprobante_MetodoPago = xNodoComprobante.Attributes.getNamedItem("MetodoPago").text
rstx!Comprobante_TipoDeComprobante = xNodoComprobante.Attributes.getNamedItem("TipoDeComprobante").text
rstx!Comprobante_Total = xNodoComprobante.Attributes.getNamedItem("Total").text
rstx!Comprobante_Moneda = xNodoComprobante.Attributes.getNamedItem("Moneda").text
rstx!Comprobante_Certificado = xNodoComprobante.Attributes.getNamedItem("Certificado").text
rstx!Comprobante_SubTotal = xNodoComprobante.Attributes.getNamedItem("SubTotal").text
rstx!Comprobante_CondicionesDePago = xNodoComprobante.Attributes.getNamedItem("CondicionesDePago").text
rstx!Comprobante_NoCertificado = xNodoComprobante.Attributes.getNamedItem("NoCertificado").text
rstx!Comprobante_FormaPago = xNodoComprobante.Attributes.getNamedItem("FormaPago").text
rstx!Comprobante_Sello = xNodoComprobante.Attributes.getNamedItem("Sello").text
rstx!Comprobante_Fecha = xNodoComprobante.Attributes.getNamedItem("Fecha").text
rstx!Comprobante_Folio = xNodoComprobante.Attributes.getNamedItem("Folio").text
rstx!Comprobante_Serie = xNodoComprobante.Attributes.getNamedItem("Serie").text
rstx!Comprobante_Version = xNodoComprobante.Attributes.getNamedItem("Version").text
rstx!Comprobante_xmlns_cfdi = xNodoComprobante.Attributes.getNamedItem("xmlns:cfdi").text
rstx!Emisor_Rfc = xNodoEmisor.Attributes.getNamedItem("Rfc").text
rstx!Emisor_Nombre = xNodoEmisor.Attributes.getNamedItem("Nombre").text
rstx!Emisor_RegimenFiscal = xNodoEmisor.Attributes.getNamedItem("RegimenFiscal").text
rstx!Receptor_Rfc = xNodoReceptor.Attributes.getNamedItem("Rfc").text
rstx!Receptor_Nombre = xNodoReceptor.Attributes.getNamedItem("Nombre").text
rstx!Receptor_UsoCFDI = xNodoReceptor.Attributes.getNamedItem("UsoCFDI").text
rstx!Impuestos_Importe = xNodoImpuestos.Attributes.getNamedItem("Importe").text
rstx!Impuestos_TasaOCuota = xNodoImpuestos.Attributes.getNamedItem("TasaOCuota").text
rstx!Impuestos_TipoFactor = xNodoImpuestos.Attributes.getNamedItem("TipoFactor").text
rstx!Impuestos_Impuesto = xNodoImpuestos.Attributes.getNamedItem("Impuesto").text
rstx!Complemento_xmlns_tfd = xNodoComplementoTFD.Attributes.getNamedItem("xmlns:tfd").text
rstx!Complemento_xsi_schemaLocation = xNodoComplementoTFD.Attributes.getNamedItem("xsi:schemaLocation").text
rstx!Complemento_Version = xNodoComplementoTFD.Attributes.getNamedItem("Version").text
rstx!Complemento_UUID = xNodoComplementoTFD.Attributes.getNamedItem("UUID").text
rstx!Complemento_FechaTimbrado = xNodoComplementoTFD.Attributes.getNamedItem("FechaTimbrado").text
rstx!Complemento_RfcProvCertif = xNodoComplementoTFD.Attributes.getNamedItem("RfcProvCertif").text
rstx!Complemento_SelloCFD = xNodoComplementoTFD.Attributes.getNamedItem("SelloCFD").text
rstx!Complemento_NoCertificadoSAT = xNodoComplementoTFD.Attributes.getNamedItem("NoCertificadoSAT").text
rstx!Complemento_SelloSAT = xNodoComplementoTFD.Attributes.getNamedItem("SelloSAT").text
rstx.Update
Next xNodoComplementoTFD
Next xNodoImpuestos
Next xNodoReceptor
Next xNodoEmisor
Next xNodoComprobante
Next oNode
'Solo funciona con MSXML2.DOMDocument
Set xListaNodoImpuestosConcepto = oXml.selectNodes("/cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado")
CountImp = 0
For Each xNodoImpuestosConcepto In xListaNodoImpuestosConcepto
CountImp = CountImp + 1
'Debug.Print CountImp & " - " & xNodoImpuestosConcepto.Attributes.getNamedItem("Importe").text
DoCmd.SetWarnings False ' Actualizo los datos faltantes de impuestos x concepto
DoCmd.RunSQL "UPDATE tblXML SET tblXML.Concepto_Impuesto_Base = '" & xNodoImpuestosConcepto.Attributes.getNamedItem("Base").text & "' , tblXML.Concepto_Impuesto_Impuesto = '" & xNodoImpuestosConcepto.Attributes.getNamedItem("Impuesto").text & "' , tblXML.Concepto_Impuesto_TipoFactor = '" & xNodoImpuestosConcepto.Attributes.getNamedItem("TipoFactor").text & "' , tblXML.Concepto_Impuesto_TasaOCuota = '" & xNodoImpuestosConcepto.Attributes.getNamedItem("TasaOCuota").text & "',tblXML.Concepto_Impuesto_Importe = " & xNodoImpuestosConcepto.Attributes.getNamedItem("Importe").text & " where id=" & CountImp & ""
DoCmd.SetWarnings True
Next xNodoImpuestosConcepto
Set oNodes = Nothing
End With
Set oXml = Nothing
End Sub