Map XML elements to cells in an XML Map (2024)

To import and export XML data in Excel, an XML Map that associates XML elements with data in cells to get the results you want will be useful. To create one, you need to have an XML schema file (.xsd) and an XML data file (.xml). After creating the XML Map, you can map XML elements the way you want.

Tip:You'll find more information about using XML with Excel in this overview of XML in Excel.

  • Locate or create XML schema and XML data files

  • Use sample XML schema and XML data files

  • Create an XML Map

  • Map XML elements

Locate or create XML schema and XML data files

If another database or application created an XML schema or XML data file, you might already have them available. For example, you might have a line-of-business application that exports data into these XML file formats, a commercial web site or web service that supplies these XML files, or a custom application developed by your IT department that automatically creates these XML files.

If you don’t have the necessary XML files, you can create them by saving the data you want to use as a text file. You can then use both Access and Excel to convert that text file to the XML files you need. Here’s how:

Access

  1. Import the text file you want to convert and link it to a new table.

    1. Click File > Open.

    2. In the Open dialog box, select and open the database in which you want to create a new table.

    3. Click External Data > Text File, and follow the instructions for each step, making sure that you link the table to the text file.

      Access creates the new table and displays it in the Navigation Pane.

  2. Export the data from the linked table to an XML data file and an XML schema file.

    1. Click External Data > XML File (in the Export group).

    2. In the Export - XML File dialog box, specify the file name and format, and click OK.

  3. Exit Access.

Excel

  1. Create an XML Map based on the XML schema file you exported from Access.

    If the Multiple Roots dialog box appears, make sure you choose dataroot so you can create an XML table.

  2. Create an XML table by mapping the dataroot element. See Map XML elements for more information.

  3. Import the XML file you exported from Access.

Notes:

  • There are several types of XML schema element constructs Excel doesn't support. The following XML schema element constructs can't be imported into Excel:

  • <any>This element allows you to include elements that aren't declared by the schema.

  • <anyAttribute>This element allows you to include attributes that aren't declared by the schema.

  • Recursive structuresA common example of a recursive structure is a hierarchy of employees and managers in which the same XML elements are nested several levels. Excel doesn't support recursive structures more than one level deep.

  • Abstract elementsThese elements are meant to be declared in the schema, but never used as elements. Abstract elements depend on other elements being substituted for the abstract element.

  • Substitution groupsThese groups allow an element to be swapped wherever another element is referenced. An element indicates it's a member of another element's substitution group through the <substitutionGroup> attribute.

  • Mixed contentThis content is declared by using mixed="true" on a complex type definition. Excel doesn't support the simple content of the complex type but does support the child tags and attributes defined in that complex type.

Use sample XML schema and XML data files

The following sample data has basic XML elements and structures you can use to test XML mapping if you don't have XML files or text files to create the XML files. Here’s how you can save this sample data to files on your computer:

  1. Select the sample text of the file you want to copy, and press Ctrl+C.

  2. Start Notepad, and press Ctrl+V to paste the sample text.

  3. Press Ctrl+S to save the file with the file name and extension of the sample data you copied.

  4. Press Ctrl+N in Notepad and repeat step 1-3 to create a file for the second sample text.

  5. Exit Notepad.

Sample XML data (Expenses.xml)

<?xml version="1.0" encoding="UTF-8" standalone="no" ?><Root> <EmployeeInfo> <Name>Jane Winston</Name> <Date>2001-01-01</Date> <Code>0001</Code> </EmployeeInfo> <ExpenseItem> <Date>2001-01-01</Date> <Description>Airfare</Description> <Amount>500.34</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-01</Date> <Description>Hotel</Description> <Amount>200</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-01</Date> <Description>Taxi Fare</Description> <Amount>100.00</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-01</Date> <Description>Long Distance Phone Charges</Description> <Amount>57.89</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-01</Date> <Description>Food</Description> <Amount>82.19</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-02</Date> <Description>Food</Description> <Amount>17.89</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-02</Date> <Description>Personal Items</Description> <Amount>32.54</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-03</Date> <Description>Taxi Fare</Description> <Amount>75.00</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-03</Date> <Description>Food</Description> <Amount>36.45</Amount> </ExpenseItem> <ExpenseItem> <Date>2001-01-03</Date> <Description>New Suit</Description> <Amount>750.00</Amount> </ExpenseItem></Root>

Sample XML schema (Expenses.xsd)

<?xml version="1.0" encoding="UTF-8" standalone="no" ?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Root"> <xsd:complexType> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="1" name="EmployeeInfo"> <xsd:complexType> <xsd:all> <xsd:element minOccurs="0" maxOccurs="1" name="Name" /> <xsd:element minOccurs="0" maxOccurs="1" name="Date" /> <xsd:element minOccurs="0" maxOccurs="1" name="Code" /> </xsd:all> </xsd:complexType> </xsd:element> <xsd:element minOccurs="0" maxOccurs="unbounded" name="ExpenseItem"> <xsd:complexType> <xsd:sequence> <xsd:element name="Date" type="xsd:date"/> <xsd:element name="Description" type="xsd:string"/> <xsd:element name="Amount" type="xsd:decimal" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:schema>

Create an XML Map

You create an XML Map by adding an XML schema to a workbook. The schema can be copied from an XML schema file (.xsd), or Excel can try to infer one from an XML data file (.xml).

  1. Click Developer > Source.

    Map XML elements to cells in an XML Map (1)

    If you don't see the Developer tab, see Show the Developer tab.

  2. In the XML Source task pane, click XML Maps, and then click Add.

  3. In the Look in list, click the drive, folder, or Internet location that contains the file you want to open.

    See Also
    Excel to XML

  4. Click the file, and then click Open.

    • For an XML schema file, XML will create an XML Map based on the XML schema. If the Multiple Roots dialog box appears, choose one of the root nodes defined in the XML schema file.

    • For an XML data file, Excel will try to infer the XML schema from the XML data, and then creates an XML Map.

  5. Click OK.

    The XML Map appears in the XML Source task pane.

Map XML elements

You map XML elements to single-mapped cells and repeating cells in XML tables so you can create a relationship between the cell and the XML data element in the XML schema.

  1. Click Developer > Source.

    Map XML elements to cells in an XML Map (2)

    If you don't see the Developer tab, see Show the Developer tab.

  2. In the XML Source task pane, select the elements you want to map.

    To select nonadjacent elements, click one element, and then hold down Ctrl and click each element you want to map.

  3. To map the elements, do the following:

    1. Right-click the selected elements, and click Map element.

    2. In the Map XML elements dialog box, select a cell and click OK.

      Tip:You can also drag the selected elements to the worksheet location where you want them to appear.

      Each element appears in bold type in the XML Source task pane to indicate the element is mapped.

  4. Decide how you want handle labels and column headings:

    • When you drag a nonrepeating XML element onto the worksheet to create a single-mapped cell, a smart tag with three commands is displayed, which you can use to control the placement of the heading or label:

      My Data Already Has a HeadingClick this option to ignore the XML element heading, because the cell already has a heading (to the left of the data or above the data).

      Place XML Heading to the LeftClick this option to use the XML element heading as the cell label (to the left of the data).

      Place XML Heading AboveClick this option to use the XML element heading as the cell heading (above the data).

    • When you drag a repeating XML element onto the worksheet to create repeating cells in an XML table, the XML element names are automatically used as column headings for the table. However, you can change the column headings to any headings that you want by editing the column header cells.

      In the XML Source task pane, you can click Options to further control XML table behavior:

      Automatically Merge Elements When MappingWhen this check box is selected, XML tables are automatically expanded when you drag an element to a cell adjacent to the XML table.

      My Data Has HeadingsWhen this check box is selected, existing data can be used as column headings when you map repeating elements to your worksheet.

      Notes:

      • If all XML commands are dimmed, and you can't map XML elements to any cells, the workbook might be shared. Click Review > Share Workbook to verify that and to remove it from shared use as needed.

        If you want to map XML elements in a workbook you want to share, map the XML elements to the cells you want, import the XML data, remove all of the XML maps, and then share the workbook.

      • If you can't copy an XML table that contains data to another workbook, the XML table might have an associated XML Map that defines the data structure. This XML Map is stored in the workbook, but when you copy the XML table to a new workbook, the XML Map isn't automatically included. Instead of copying the XML table, Excel creates an Excel table that contains the same data. If you want the new table to be an XML table, do the following:

        1. Add an XML Map to the new workbook by using the .xml or .xsd file you used to create the original XML Map. You should save these files if you want to add XML Maps to other workbooks.

        2. Map the XML elements to the table to make it an XML table.

      • When you map a repeating XML element to a merged cell, Excel unmerges the cell. This is expected behavior, because repeating elements are designed to work with unmerged cells only.

        You can map single, nonrepeating XML elements to a merged cell, but mapping a repeating XML element (or an element that contains a repeating element) to a merged cell isn't allowed. The cell will be unmerged, and the element will be mapped to the cell where the pointer is located.

Tips:

  • You can unmap XML elements you don't want to use, or to prevent the contents of cells from being overwritten when you import XML data. For example, you could temporarily unmap an XML element from a single cell or repeating cells that have formulas you don't want to overwrite when you import an XML file. When the import is complete, you can map the XML element to the formula cells again, so you can export the results of the formulas to the XML data file.

  • To unmap XML elements, right-click their name in the XML Source task pane, and click Remove element.

Show the Developer tab

If you don't see the Developer tab, do the following to display it:

  1. Click File > Options.

  2. Click the Customize Ribbon category.

  3. Under Main Tabs, check the Developer box, and click OK.

See Also

Delete XML map information from a workbook

Append or overwrite mapped XML data

Overview of XML in Excel

Import XML data

Export XML data

Map XML elements to cells in an XML Map (2024)

FAQs

Map XML elements to cells in an XML Map? ›

Open the "Data" tab in the menu bar at the top of the sheet. In the "Get & Transform" group, select the "Get Data" option. This opens a drop-down menu with several source options to retrieve data from. When importing a downloaded XML file, select "From File" in the drop menu and click on "From XML" on the side menu.

How to convert XML sitemap to Excel? ›

Open the "Data" tab in the menu bar at the top of the sheet. In the "Get & Transform" group, select the "Get Data" option. This opens a drop-down menu with several source options to retrieve data from. When importing a downloaded XML file, select "From File" in the drop menu and click on "From XML" on the side menu.

What is XML mapping in Excel? ›

In general, XML maps are used to create mapped cells and to manage the relationship between mapped cells and individual elements in the XML schema. In addition, these XML maps are used to bind the contents of mapped cells to elements in the schema when you import or export XML data files (. xml).

What is a map in XML? ›

Using XML Object Syntax to Map Objects

You can use XML Object syntax to define map objects as follows: <Map> <MapEntry key='name' value='Jeff'/> <MapEntry key='phone' value='338-1818'/> </Map> Previous: Example Form Using Both Types of Syntax.

What is data mapping in XML? ›

In the XML map editor, you map elements and attributes between source and target business objects or messages, and then you apply transform logic that specifies the action to be performed on the source data. The result of the transform is stored in the target element.

How to extract data from XML into Excel? ›

If you have an XML Map, do this to import XML data into mapped cells:
  1. In the XML Map, select one of the mapped cells.
  2. Click Developer > Import. If you don't see the Developer tab, see Show the Developer tab.
  3. In the Import XML dialog box, locate and select the XML data file (. xml) you want to import, and click Import.

How to convert XML to CSV in Excel? ›

How to convert an XML file to CSV or Excel Spreadsheet
  1. Open the XML file and select all the text by clicking Ctrl + A then copy it by clicking Ctrl+C.
  2. Open Notepad ++ and paste the text from the previous step. ...
  3. From the top menu, open the Language sub-menu, then select XML.

How to map the XML elements? ›

To map the elements, do the following:
  1. Right-click the selected elements, and click Map element.
  2. In the Map XML elements dialog box, select a cell and click OK. Tip: You can also drag the selected elements to the worksheet location where you want them to appear.

What is XML sitemap example? ›

An XML sitemap is a file that lists a website's essential pages, making sure Google can find and crawl them all. It also helps search engines understand your website structure. You want Google to crawl every important page of your website. But sometimes, pages end up without internal links, making them hard to find.

How do I map data from Excel to XML? ›

To convert Excel to XML, you can follow these steps:
  1. Create an Excel spreadsheet.
  2. Create an XML schema.
  3. Enable the Developer tab.
  4. Open the XML Source pane.
  5. Map XML file to Excel file.
  6. Convert Excel file to XML file.
  7. Save the XML file.

What is an example of data mapping? ›

For example, the state field in a source system may show Illinois as "Illinois," but the destination may store it as "IL." Data mapping bridges the differences between two systems, or data models, so that when data is moved from a source, it is accurate and usable at the destination.

What language is XML? ›

Extensible Markup Language (XML) is a markup language that provides rules to define any data.

How to organize data in XML? ›

This data is organized in the form of elements, and each element has its own set of tags that define it. These tags can be used to distinguish one element from another so that computer programs can easily interpret the data contained within the file. At the top of an XML file is the root element.

How to view XML files in Excel? ›

Right-click on the file, and choose: Open With: Microsoft Excel If Microsoft Excel doesn't show up in your list of choices, then select: Open With: Choose Program. Excel will be a choice in the list B. Use Excel to navigate to, and open the file. To do this, first open Excel, then in the menu, choose File: Open.

How to save an XML file in Excel? ›

Save XML data in mapped cells to an XML data file
  1. Press Ctrl+S to save your file. ...
  2. Click File > Save As, and select the location where you want to save the file. ...
  3. In the File name box, type a name for the XML data file.
  4. In the Save as type list, click XML Data, and click Save.

How do I export a website map to Excel? ›

Open the Site> Pages in the Site Navigation> Click on three dots in the ribbon> Export to Excel> Open the downloaded file. Note: The same steps can be performed in the Document Library and List.

How do I change the default XML to Excel? ›

Go to the . xml file and set the default program to open the file as excel. If you now go to Control Panel>Default Programs>Set Associations, you should see that the . xml extension has Excel listed as the default program.

Top Articles
How to Legally Get Windows 10 Key for Free or Cheap
How To Add & Remove A Family Member
UPS Paketshop: Filialen & Standorte
Unit 30 Quiz: Idioms And Pronunciation
Uca Cheerleading Nationals 2023
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
12 Rue Gotlib 21St Arrondissem*nt
Www.politicser.com Pepperboy News
The Potter Enterprise from Coudersport, Pennsylvania
Retro Ride Teardrop
What Was D-Day Weegy
Heska Ulite
Spelunking The Den Wow
Ukraine-Russia war: Latest updates
World History Kazwire
Trini Sandwich Crossword Clue
Insidekp.kp.org Hrconnect
Nba Rotogrinders Starting Lineups
Enterprise Car Sales Jacksonville Used Cars
Bitlife Tyrone's
Blackwolf Run Pro Shop
Epro Warrant Search
Accident On May River Road Today
[PDF] PDF - Education Update - Free Download PDF
Johnnie Walker Double Black Costco
Cpt 90677 Reimbursem*nt 2023
Malluvilla In Malayalam Movies Download
When His Eyes Opened Chapter 3123
Craigslist Northern Minnesota
Orange Park Dog Racing Results
Rs3 Bring Leela To The Tomb
How rich were the McCallisters in 'Home Alone'? Family's income unveiled
Babydepot Registry
Planned re-opening of Interchange welcomed - but questions still remain
Bursar.okstate.edu
Miss America Voy Board
M3Gan Showtimes Near Cinemark North Hills And Xd
CARLY Thank You Notes
Edict Of Force Poe
Manatee County Recorder Of Deeds
Woodman's Carpentersville Gas Price
Linda Sublette Actress
R/Moissanite
Windshield Repair & Auto Glass Replacement in Texas| Safelite
Arch Aplin Iii Felony
Okta Login Nordstrom
Every Type of Sentinel in the Marvel Universe
St Als Elm Clinic
Who Is Nina Yankovic? Daughter of Musician Weird Al Yankovic
David Turner Evangelist Net Worth
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 6392

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.