Add an XML file as a data source

Your enterprise is storing more and more data in XML files. To make this data more accessible on your site, you want to use these XML files as data sources. With Microsoft SharePoint Designer 2010, you can easily add a connection to an XML file as a data source. After you connect to the XML file, you can create a view of data in the XML file by creating a Data View. To learn more about Data Views, see the article Create data views.

You can add an XML file as a data source to your site in any of three different ways. You can:

  • Create an XML file in SharePoint Designer 2010 and save it as part of your Web site.
  • Import an XML file from a file or folder on your computer or network.
  • Connect to an XML file that resides on an external server.

When you create or import a new XML file, a corresponding connection automatically appears in the Data Sources list in the Navigation pane. By default, every XML file in a site has a corresponding data source connection in the Data Sources list.

What do you want to do?


Create an XML file

When you create an XML file in SharePoint Designer 2010 and save it as part of your Web site, a corresponding data source connection automatically appears in the Data Sources list.

  1. On the File menu, click New.
  2. In the New dialog box, on the Page tab, click General, and then click XML.
  3. Click OK.

A new XML file with an XML DOCTYPE declaration (<?xml version="1.0" encoding="utf-8" ?>) opens in your Web site.

  1. In SharePoint Designer 2010, position the insertion point after the XML DOCTYPE declaration, and then press ENTER to begin your XML file. After you create your XML file, make sure that the </xml> closing tag is included.
  2. On the File menu, click Save As.
  3. In the File name box, type a name for your XML file, and then click Save.

 Notes 

  • When you work with an XML file as a data source, the XML file must contain only well-formed XML. Invalid markup may cause errors. To validate the XML file, open the XML file, and click the Edit tab on the ribbon, and under Code Formatting, click Verify well-formed XML.
  • In addition, either the XML file must contain and conform to a schema, or it must contain data from which a schema can be inferred.

Top of Page Top of Page

Import an XML file located on your computer or network

When you import an XML file into a site, a corresponding connection automatically appears in the Data Sources list.

  1. Click Data Sources in the Navigation Pane.
  2. On the Data Sources tab on the ribbon, in the New group, click XML File Connection.
  3. In the Data Source Properties dialog box, in the Location box on the Source tab, type the path to the XML file that you want, or click Browse to locate and select it.

Location box on Source tab in Data Source Properties dialog box

  1. Click OK.

 Notes 

  • When you work with an XML file as a data source, the XML file must contain only well-formed XML. Invalid markup may cause errors. To validate the XML file, open the XML file in SharePoint Designer 2010, click the Edit tab on the ribbon, and under Code Formatting, click Verify well-formed XML.
  • In addition, either the XML file must contain and conform to a schema, or it must contain data from which a schema can be inferred.

Top of Page Top of Page

Connect to an XML file located on an external server

When you connect to an XML file located on an external server (unlike when you import an XML file on your own computer or network), you do not import the file to your site. Instead, you link to it directly by using the URL of the external XML file.

  1. Click Data Sources in the Navigation Pane.
  2. On the Data Connections tab, in the New group, click XML File Connection.
  3. In the Data Source Properties dialog box, in the Location box on the Source tab, type the URL for the XML file that you want, or click Browse to locate and select it.
  4. Click OK.

If the XML file resides in a site that requires a user name and password, you are prompted to provide these credentials.

  1. The XML file may also require logon credentials beyond those for the current Microsoft SharePoint site. You might need a user name and password to change the properties or to access the data, for example. If you know that you need additional credentials, click Login tab in the Data Source Properties dialog box, and then click one of the following options:
    • Don't attempt to authenticate    This option either attempts an anonymous connection or supplies the current team member's credentials. Select this option if the XML file is not password-protected or if you want to require team members to use their user names and passwords to access any protected files.
    • Save this user name and password in the data connection    This option stores the provided user name and password so that anyone can access the file. Use this option if you want to bypass any existing password protection by typing the user name and password in the corresponding boxes.
    • Use Windows authentication    This option uses the current team member's user name and password. This option works only when Microsoft SharePoint Foundation and the XML file are located on the same server.
    • Use Single Sign-On authentication (requires Microsoft SharePoint Server 2010)    This option is only available when your site is part of a portal site created by using Office SharePoint Server 2010 and when the administrator has enabled and configured Single Sign-On authentication. If you want to use Single Sign-On authentication, select this option, and then click Settings. In the Single Sign-On Settings dialog box, do the following:
      • In the Application Name box, type the application name for your database.
      • In the Application field to use as the user name box, type the name of the field in which your user name is stored.
      • In the Application field to use as the password box, type the name of the field in which your password is stored.

If you do not have the necessary information, contact your server administrator.

 Notes 

  • When you work with an XML file as a data source, the XML file must contain only well-formed XML. Invalid markup may cause errors. To validate the XML file, open the XML file in SharePoint Designer 2010, click the Edit tab on the ribbon, and under Code Formatting, click Verify well-formed XML.
  • In addition, either the XML file must contain and conform to a schema, or it must contain data from which a schema can be inferred.

Top of Page Top of Page

 
 
Applies to:
SharePoint Designer 2010