Import XML into Excel

manubd

New Member
Joined
Aug 15, 2013
Messages
3
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.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top