Sure. I posted some sample code on Microsoft's public form the other day:
public void SharePointListAdapterDropDown_OnAfterChange(DataDOMEvent e)
{
// filter out noise
if (e.IsUndoRedo || "Insert" != e.Operation || "" == e.NewValue)
return;
// prevent infinite loops when loading files from ShP
if(true == fGettingSharePointFile)
{
fGettingSharePointFile = false;
return;
}
fGettingSharePointFile = true;
// get the selection
string sKey = e.Site.text;
// "test" is the name of your sharePoint list adapter data connection
SharepointListAdapter oSpla =
(SharepointListAdapter)thisXDocument.DataAdapters["test"];
sUrl = oSpla.SiteUrl;
// "test" is also the name of a secondary data source that you will
pre-populate
IXMLDOMDocument2 oDom = (IXMLDOMDocument2)thisXDocument.GetDOM("test");
oDom.setProperty("SelectionNamespaces",
"xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolut
ion\"");
// filter on the value using sKey
string sName =
oDom.selectSingleNode(string.Format("//dfs:test[@key1=\"{0}\"]/@Value",
sKey)).text;
// Note: you need to set sSP_FOLDER to your SharePoint folder
// - you can do this programmatically using SolutionURL and walking up the
string sFilename = sUrl + sSP_FOLDER + sName;
// random schema - please change to suit your insertion needs
IXMLDOMNode oParentNode = getNode("//my:root/my:section1");
IXMLDOMNode oNode = getNode("//my:root/my:section1/rd:section2");
// Load the XML DOM from the file
IXMLDOMDocument2 oXml = (IXMLDOMDocument2)thisXDocument.CreateDOM();
oXml.async = false;
oXml.load(sFilename);
oXml.setProperty("SelectionNamespaces",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:rd=\"http://www.infopathdev.com/Samples/ShP/GetFile\"
xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"
xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-1
7T17:30:19\"
xmlns:xd=\"http://schemas.microsoft.com/office/infopath/2003\"");
// Note: be careful calling replaceChild since it can be slow
IXMLDOMNode oNewNode = oXml.selectSingleNode("//my:root/my:section1//" +
oExistingNode.nodeName);
oParentNode.replaceChild(oNewNode.cloneNode(true), oExistingNode);
return true;
}
Patrick Halstead [InfoPath MVP]
InfoPathDev
Patrick Halstead
Project Manager at Qdabra