Betsy Rolland
LIS 600 Independent Study
Transforming XML to Microsoft XML
Terry Brooks
Winter 2006
Excel's support for XML is, in my opinion, complicated and disappointing. While opening an XML file in Word gives you the option of either displaying the XML file "as-is" or applying an XSLT stylesheet, Excel has neither of those options. When you open an XML file in Excel, you have three options:
Each of these has its advantages and disadvantages, as discussed below. One of the most interesting things about working with XML data in Excel is that, while it's relatively easy to get the data into your spreadsheet, there is no way to save the data only if your XML file has more than two levels of elements. When Excel opens an XML file, it "flattens" it into a list format rather than maintaining the schema's hierarchy. Thus, when it's time to export back to XML, Excel won't allow you to export something like this:
Your only option appears to be to save the data as SpreadsheetML, then use XSLT to transform the data back to straight XML, which seems like a huge waste of effort. At the bottom of the XML Source Task Pane, there's a button to "Verify Map for Export." Clicking this button will tell you if your XML can be exported or not. On the XML structure above, verifying the map for export gives this error message:
Because the XML data we're working with allows multiple instances of "snack food," Excel can't export it. If I edit the XML file and ensure each "person" has only one "snack food", the XML is exportable.
Another issue with repeating elements is how Excel displays them. Because the fundamental structure of Excel is the table, Excel displays the XML data in the form of columns and rows. If an element has a repeating element, Excel repeats all the data for its parent and sibilings, too, like this, obscuring the fundamental structure of the XML:
Each of the three "open as" options behaves differently.