Excel Import XML into Excel

Aug 17, 2013
Reaction score
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.

-<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"/>

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.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question