Import xml intro excel

fabesmoros

New Member
Joined
Sep 26, 2014
Messages
3
I am importing an xml file into excel using VBA code. I am able to import the complete file but I would like to only import certain information.

The code I have to import the whole xml:
Sub ImportXMLtoList()
Dim strTargetFile As String
Application.DisplayAlerts = False
strTargetFile = "C:\Users\adrros\Desktop\Practice\TranD.xml"
Workbooks.OpenXML Filename:=strTargetFile, LoadOption:=xlXmlLoadImportToList
Application.DisplayAlerts = True
End Sub

This is an example of the mapping of the xml:
<requests>
<request="abc" referencenumber="1234" date="2014-09-22" id="123456789">< Requests > -< Request Source="ABC" MerchantReferenceNumber="11235456" RequestDate="2014-8-22" RequestID="123456789456123" >
-< BillTo >
< FirstName > JOHN < /FirstName >
< LastName >smith< /LastName >
< Address1 >123 JOHN STREET < /Address1 >
< City >NEW York< /City >
< State >NY< /State >
< Zip >326544< /Zip >
< Email >JOHNSMITH@HOTMAIL.COM< /Email > < Country >US< /Country >
< Phone >30526445698< /Phone >
< IPAddress >111.11.111.111< /IPAddress >
< /BillTo >
< ShipTo >
< FirstName > JOHN < /FirstName >
< LastName >smith< /LastName >
< Address1 >123 JOHN STREET < /Address1 >
< City >NEW YORK< /City >
< State >NY< /State >
< Zip >326544< /Zip >
< Country >US< /Country >
< /ShipTo >
< Shipping >
< Method >oneday< /Method >
< Carrier/ >
< /Shipping >

I would only like to import the ReferenceNumber and the ID
The complete <bill to=""> information
And the Zip Code and State from the Shipping information.

Thanks for your help
</bill></request="abc"></requests>
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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