Excel Import XML into Excel

Joined
Aug 17, 2013
Messages
2
Reaction score
0
Hello Guys,

Hope you can help me with this piece of code that i'm struggling with, what i want is to import to excel both children's "importe" amounts for each of the cfdi:Trasladado's Parent below, here is the piece of the xml and the vba code i'm using.

XML:
-<cfdi:Impuestos totalImpuestosTrasladados="42.39">
- <cfdi:Traslados>
<cfdi:Traslado importe="9.20" tasa="0.36" impuesto="IEPS"/>
<cfdi:Traslado importe="33.19" tasa="16.00" impuesto="IVA"/>

VBA CODE:
ElseIf Trim(Cells(2, y)) = "/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado/@impuesto" Or _ ' Code to import IVA importe
Trim(Cells(2, y)) = "/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado/@importe" Then
IVA = Cells(3, y)
ElseIf Trim(Cells(2, y)) = "/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado/cfdi:Traslado/@impuesto" Or _ ' Code to import IESP importe
Trim(Cells(2, y)) = "/cfdi:Impuestos/cfdi:Traslados/cfdi:Traslado/cfdi:Traslado/@importe" Then
IEPS = Cells(2, y)

The problem is that since there are two children with the same name it just import the first children's importe and for the second doesn't import anything.

by the way I have a column in my excel worksheet called IVA (column I) and in column L i have the IEPS column so when i run the macro it just import the first children amount in the IVA column (the code doesn't recognize the columns name).

any help will be appreciated.
 
Back
Top