The content of this section:
How to use a data connection in InfoPath to get data from an XML file
How to modify the XML file path in a data connection through code
Open Visual Studio 2008 and create a new project for your project template with an InfoPath 2007 form template.
After the project is created, you will see an empty mainifest.xsf file, which is the design area of the InfoPath form, and we can design the form using the Toolbox and the Layout panel.
Instead of rushing to design the form, we add a data connection. To make the example more interesting, I chose the Google Picasa Web album RSS as the external data, and the InfoPath form gets the album list from the RSS file and presents it.
The method for adding this data connection is as follows:
Click Manage data connections in the data Sources panel.
In the Pop-up Data Connection dialog box, click Add;
In the Data Connection Wizard dialog box that pops up, select New connection and receive data only, and click Next.
Select "XML Document" as the data source, click "Next";
In the XML Location text box, enter a Google Picasa Web album album RSS address, click "Next";
Select "Access data from the specified location" and click "Next";
Enter the name "Getalbum", check "automatically retrieve data when opening form", and click "Finish".
When you open the data source panel and switch the data source to the getalbum you just created, you'll see that InfoPath has imported the schema for that RSS file.