Create a data connection to an XML file in InfoPath 2010
Learn how to create a data connection to retrieve data from an XML file that is stored as a resource file in an InfoPath 2010 browser-enabled form template that is to run in InfoPath Forms Services in SharePoint 2010 and filled out through a browser.
InfoPath 2010 supports connecting to several types of external data sources to retrieve data. Examples include Web Services, SharePoint List, Databases, and XML files.
This article lists the steps to create a data connection to an XML file that is stored as a InfoPath resource file of a browser-enabled form template.
Once such a data connection is created, the XML file then becomes a secondary data source of the InfoPath form template.
To create a data connection to an XML file to retrieve data:
- In InfoPath 2010, create a new Blank Form template.
- On the Data tab under the Get External Data group, click From Other Sources, and then click From XML File.
Figure 1. Get external data from an XML file in InfoPath 2010.
- On the Data Connection Wizard, click Browse to browse to and select an XML file, and then click Next.
- Connections to XML files on the local computer, or in a network folder, are not allowed in Web browser forms, so you are forced to include the XML file as a resource file in the form template. This means that the XML file will become part of the .XSN file that makes up the InfoPath form template. Click Next.
- Change the name of the data connection if you wish, leave the Automatically retrieve data when form is opened check box selected, and then click Finish.
You can double-check that the XML file was indeed added as a resource file in the InfoPath form template by clicking on Resource Files under the Form Data group on the Data tab on the Ribbon.
Now you can use the data connection to the XML file as the data source for for example a drop-down list box.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.
Related InfoPath Articles:
- InfoPath Basics: Main vs. secondary data sources
- How to add a data connection to a SharePoint list or library in InfoPath
- How to extract the month name from a date picker in InfoPath
- Import data from Excel 2010 into InfoPath 2010
- Pre-select items in a Multiple-Selection List Box in InfoPath 2010