In order export an Excel 2010 worksheet to XML you have to add XML Mappings to the file. This process is a bit different from previous Excel versions so here is a step by step on how to achieve this.
For this blog I have an Excel 2010 file containing some news articles that I would like in XML format.
Create an .xsd file for the XML Mappings
<?xml version="1.0" encoding="UTF-8"?>
<xs:element ref="NewsItemRow" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="newstitle" type="xs:string"/>
<xs:element name="newsdate" type="xs:dateTime"/>
<xs:element name="newssummary" type="xs:string"/>
<xs:element name="newstext" type="xs:string"/>
The .xsd file contains the mappings for our XML. For this tutorial I have added fields for news articles, which match the Excel file I will be using. Note the different types of elements we will be using.
Add the developer toolbar to the ribbon
Select File menu, then Options.
On the “Customize Ribbon” tab, check “Developer” tab in the right column.
Add the .xsd file as an XML Source
Click the Developer toolbar and select “Source” to display the “XML Source” pane.
Click “XML Maps” to add the .xsd file.
Select the root for the mappings as “NewsItemsTable”
Confirm the XML Map was imported correctly
Be sure your XML Mappings Options are marked to “Automatically Merge Elements When Mapping” and “My Data Has Headings”
Map the columns to elements
Select the columns you would like to map in the Excel file
In the “XML Source” pane, right click the “NewsItemsTable” node and select “Map element”
Confirm the columns were mapped correctly
Export to XML
On the “Developer toolbar”, click “Export”
You will now have an XML file containing the Excel data with the mappings you defined.