Excel Open XML File
Last Updated :
-
Blog Author :
Edited by :
Reviewed by :
Table Of Contents
What Is Excel Open XML File?
With Excel data, we can convert the data into XML format. XML stands for eXtensible Markup Language.We need to know how we can import data from different sources. The source file varies from one situation to another.
We are familiar with common file extensions: “Text file and Excel file.” But several other sources are also available. This article will show us how to open Excel data into XML format and import XML data into Excel with neat formatting.
Table of contents
- XML stands for eXtensible Markup Language. It is a language that can be read only by computers.
- The XML files follow a certain script, so we need to follow a mandatory line of codes.
- When we open our XML file, it will open with TEXT File only, but remember, the format will be in XML Schema.
- We need to create at least two schema examples to apply the same logic to the whole data and export it as an XML file.
What Is XML File?
EXtensible Markup Language of storing data in the XML format. Like all the other external database rules, XML, too, has its own standard set of actions.
The following are the rules of the XML file:
- The first line of the data should always include the below line of code.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- XML format has the head and tail of the table name.
<TableName> Column1<Value>Column1 Column2<Value>Column2 <TableName> <TableName> Column1<Value>Column1 Column2<Value>Column2 <TableName>
Like this, we can create an XML table to convert the excel data into an XML table format. Now we will see how to open excel data into XML format.
Example Of Converting Excel Data To XML File Format
For example, look at the below data in the Excel worksheet.
First_Name | Last_Name | City | Country |
---|---|---|---|
James | Butt | New Orleans | Orleans |
Josephine | Darakjy | Brighton | Livingston |
Art | Venere | Bridgeport | Gloucester |
Lenna | Paprocki | Anchorage | Anchorage |
Donette | Foller | Hamilton | Butler |
Simona | Morasca | Ashland | Ashland |
Mitsue | Tollner | Chicago | Cook |
Loeta | Dilliard | San Jose | Santa Clara |
Sage | Wieser | Sioux Falls | Minnehaha |
Kris | Marrier | Baltimore | Baltimore City |
Minna | Amigon | Kulpsville | Montgomery |
Abel | Maclead | Middle Island | Suffolk |
Now, we need to convert this into an XML excel format as shown in the below image.
Here, we need to create two sample lines formatting for our data. As we have discussed, our rules for creating a mandatory line of code are below.
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
Next, we need to enter the table name as per our wish. So, let us enter the table name as <EmpRecord>
Then, after the table name, we need to enter the column header name, <FirstName> next; Remember, we need to include the name and end this with the column header again.
Likewise, we need to prepare a schema of XML data. For the above data, we have created the schema. Then, we can copy and paste the schema.
<?xml version="1.0" encoding="UTF-8"?> <dataset> <EmpRecord> <FirstName>James</FirstName> <LastName>Butt</LastName> <City>New Orleans</City> <Country>Orleans</Country> </EmpRecord> <EmpRecord> <FirstName>Josephine</FirstName> <LastName>Darakjy</LastName> <City>Brighton</City> <Country>Livingston</Country> </EmpRecord> </dataset>
We have created two samples. So, by using this, we can apply the same schema to our Excel file and extract data in the same format (XML) as provided above.
We must copy the above code to a text file and save the file as “XML.”
We must follow the below steps to open the Excel data into XML format.
- Step 1: First, in the data workbook, we must go to the “Developer” tab and then, click on “Source.”
- Step 2: Next, this will open up below the “XML Source” window to the right of the worksheet, and click on “XML Maps.”
- Step 3: This will open up the “XML Maps” window, then click on the “Add” button to choose the XML schema file.
- Step 4: Now, choose the already saved XML file with the schema.
- Step 5: Next, click on “Open.” It will ask for our confirmation.
- Step 6: Now, we need to click on “OK” two more times to get the schema headers to the left.
- Step 7: Now, drag and drop the first column header “FirstName” from the XML source to the actual table in the worksheet.
As a result, this will apply the “FirstName” column schema to the data table column.
Now, we must repeat the same for the remaining columns. So, drag and drop respective schema columns to individual columns of the data table.
Now, all the XML schema columns are applied. Then, under the “Developer” tab excel, click on the "Export" option.
Now, it will ask us to save the file in the desired folder. So, we must give a name and save it.
Next, after choosing the folder, we must click on “Export.” The data will be extracted as the “XML Data” file.
Now, open the file, and we can see all the rows in the XML format.
Likewise, we can extract or open the Excel data to the XML file.
Import XML Data Into Excel
Importing an XML file to Excel requires following certain steps. First, follow the below steps to import data from an XML file.
- First, under the “Data” tab, we must click on “Get Data” → “From File” and choose “From XML.”
- Consequently, this will ask us to choose the file from the stored location. Therefore, we need to select the file.
- Next, click on “Import.” It will import the data into an Excel file.
Likewise, we can work with “XML files” in Excel.
Important Things To Note
- XML language is a computer language but it is not read by humans.
- XML stands for eXtensible Markup Language.
- We can import XML files in excel using the Import option under the Data tab.
Frequently Asked Questions (FAQs)
XML, eXtensible Markup Language is a language read by computer to define text. XML is just like HTML. We can import XML files in excel.
We can easily open XML file in excel using the below steps:
• Step 1: First, go to Data → Get Data → From File → From XML
• Step 2: Next, the Import Data window opens.
• Step 3: Then, select the file and click Import.
Finally, the XML file will be imported.
While using XML in excel, it is important to know that
• XML has mandatory code lines.
• Whenever we import XML file, it will open with TEXT File only, but the format is in XML Schema.
Recommended Articles
This article has been a guide to Excel Open XML File. Here, we discuss exporting Excel data into XML format and importing XML data into Excel. You may learn more about Excel from the following articles: –