How to Convert XML to Columns In Excel (4 Suitable Ways)

In this tutorial, I am going to show you 4 suitable ways to convert XML to columns in Excel. You can use these methods even in large datasets to find out the data cells from XML data values. Throughout this tutorial, you will also learn some important Excel tools and techniques that will be very useful in any Excel-related task.


How to Convert XML to Columns in Excel: 4 Suitable Ways

We have taken a relatively concise XML dataset to explain the steps clearly. The dataset has approximately 7 rows and 2 columns. Initially, we are keeping all the cells in General format. For all the datasets, we have 2 unique columns which are Site Location URL and Date. Although we may vary the number of columns later on if that is needed.


1. Using XML from Local System

In this first method, we will convert XML to columns in Excel from our local system. Let us see how to do this.

Steps:

  • First, go to the Data tab and click on Get Data.
  • Next, select From File and then click on From XML.

convert xml to columns in excel

  • Now, select an XML file and click Import.

using local system to convert XML to columns in excel

  • Then, in the Navigator window, select the XML data name and click Load.

  • Consequently, this will create Excel columns from the imported file.

using local system to convert XML to columns in excel

Read More: How to Extract Data from XML File to Excel


2. Fetching XML from Web

We can also fetch XML data from the web using URL and convert it to columns in Excel. Follow the steps below for this.

Steps:

  • To begin with, go to the Data tab and click From Web.

web url to convert XML to columns in excel

  • Here, paste the URL of the XML file and click OK.

web url to convert XML to columns in excel

  • Now, select the appropriate file path and click Connect.

  • As before, select the XML data name and click Load.

  • Immediately, you should get the respective Excel columns.

Read More: How to Convert XML to XLSX Without Opening File


3. Applying FILTERXML Function

The FILTERXML function in Excel gives us the ability to convert cell data into columns from XML data. Below are the detailed steps.

Steps:

  • To start with, copy the XML file data and paste it into cell B4 of an Excel sheet.

filterxml function to convert XML to columns in excel

  • Then, go to a new sheet and insert this formula in cell B5:
=FILTERXML(FILTERXML!B5,"//PLANT/COMMON")

  • Finally, press Enter and this should generate the Excel columns from the XML file as we wanted.


4. Utilizing VBA Code

If you are familiar with VBA in Excel, then you can easily convert XML to columns using just a few lines of code.

Steps:

  • For this method, go to the Developer tab and select Visual Basic.

vba code to convert XML to columns in excel

  • Now, select Insert in the VBA window and click on Module.

  • Next, type in the formula below in the new window:
Sub XML_to_Column()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wBook As Workbook
With Workbooks.OpenXML("C:\Users\ASUS\Downloads\sitemap_index.xml" _
, , xlXmlLoadImportToList)
.SaveAs ("C:\Users\ASUS\Downloads\Salary_Sheet.xlsx")
.Close
End With
End Sub

  • Then, open the macro from the Developer tab by clicking on Macros.

  • Now, in the Macro window, select the XML_to_Column macro and click Run.

  • As a result, the VBA code will create the columns inside cells B4 to C10.

Read More: How to Convert Large XML to Excel


How to Convert XML to CSV in Excel

If you want to convert an XML file to CSV, then there is a very easy option to do this. Let us see that.

Steps:

  • Firstly, click on the File option in the top-left corner of the window.

How to Convert XML to CSV in Excel

  • After that, select Export and then click on Change File Type.

  • Here, select CSV under Other File Types and click Save As.

  • Next, give a name to the file and click Save.

  • As a result, this will generate the CSV file which you can open with Notepad or any other text editor.

Read More: How to Open XML File in Excel


How to Convert XML to Excel Table

We can also convert an XML file directly into an Excel table. The process is somewhat similar to what we have seen already. So, let us follow the steps below.

Steps:

  • As previously, navigate to the Data tab and select Get Data.
  • Then, click From XML under From File.

How to Convert XML to Excel Table

  • Next, select the XML file and click Import.

  • Now, select the XML data name and click Load To.

  • Then, in the Import Data window, select Table and click OK.

  • Finally, this will convert the XML file into an Excel table.

Read More: How to Convert XML to Excel Table


Download Practice Workbook

You can download the practice workbook from here.


Conclusion

I hope that you were able to apply the methods that I showed in this tutorial on how to convert XML to columns in Excel. As you can see, there are quite a few ways to achieve this. So wisely choose the method that suits your situation best. If you get stuck in any of the steps, I recommend going through them a few times to clear up any confusion. If you have any queries, please let me know in the comments.


Related Articles

<< Go Back to Import XML to Excel | Importing Data in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Nazmul Hossain Shovon
Nazmul Hossain Shovon

Nazmul Hossain Shovon, a BUET graduate in Naval Architecture and Marine Engineering, embarked on his career with 8 months dedicated to the Exceldemy project's triumph. Transitioning into a Software Developer role, he specialized in web add-in development. At Exceldemy, he authored about 125 blog articles and solved many visitors’ problems, refining his writing skills and delving into Excel-related topics. With a primary passion for programming and software development, Shovon continually explores new horizons, fostering professional growth in his... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo