共用方式為


XMLFileAdapterObject 介面

代表到 XML 檔案的連線。

**命名空間:**Microsoft.Office.Interop.InfoPath
**組件:**Microsoft.Office.Interop.InfoPath (於 microsoft.office.interop.infopath.dll 中)

語法

'宣告
<CoClassAttribute(GetType(XMLFileAdapterObjectClass))> _
<GuidAttribute("096CD5D5-0786-11D1-95FA-0080C78EE3BB")> _
Public Interface XMLFileAdapterObject
    Inherits XMLFileAdapter2
'用途
Dim instance As XMLFileAdapterObject
[CoClassAttribute(typeof(XMLFileAdapterObjectClass))] 
[GuidAttribute("096CD5D5-0786-11D1-95FA-0080C78EE3BB")] 
public interface XMLFileAdapterObject : XMLFileAdapter2

備註

此類型為 coclass 的包裝函式,屬於 COM 互通性中 Managed 程式碼的必要項。使用此類型,即可存取由此 coclass 實作的 COM 介面成員。如需 COM 介面 (包括其成員說明連結) 的詳細資訊,請參閱 XMLFileAdapter2

XMLFileAdapterObject 物件是一種 Microsoft Office InfoPath 2003 資料中繼層,它包含所有從外部資料來源擷取資料所需的資訊。

XMLFileAdapterObject 物件提供 FileURL 屬性,可用於取得或設定做為外部資料來源的 XML 檔案之「統一資源定位器」(URL)。

至於次要資料來源,XMLFileAdapterObject 物件可以透過 DataSourceObjectQueryAdapter 屬性和 DataAdaptersCollection 集合的 Item 屬性來存取。

DataObject 物件是透過 XDocument 物件的 DataObjects 屬性來存取。

範例

DataAdapters dtaAdapters;
dataAdapters = thisDocument.DataAdapters; 
XMLFileAdapterObject queryXMLFile = dataAdapters["form1"] as XMLFileAdapterObject;
if (queryXMLFile == null)
{
 thisXDocument.UI.Alert("The DataAdapter does not exist or is not an XMLFileAdapterObject.");
}
else
{
 thisDocument.UI.Alert("Query - XML file adapter"); 
 thisDocument.UI.Alert("Name: " + queryXMLFile.Name);
 thisDocument.UI.Alert("QueryAllowed: " + queryXMLFile.QueryAllowed);
 thisDocument.UI.Alert("SubmitAllowed: " + queryXMLFile.SubmitAllowed);
 thisDocument.UI.Alert("FileURL: " + queryXMLFile.FileURL);
 // Perform the query.
 try
 {
  queryXMLFile.Query();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to query.\n\n" + ex.Message);
 }
 // Perform the submit.
 try
 {
  queryXMLFile.Submit();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to submit.\n\n" + ex.Message);
 }
}

請參閱

參考

XMLFileAdapterObject 成員
Microsoft.Office.Interop.InfoPath 命名空間