1

When I deploy an Infopath 2007 form to the SharePoint server, the SelectSingleNode always returns null but always works locally. Here is an example of the following code that is failing:

XPathNavigator vendor = payeeDS.SelectSingleNode(
"/dfs:myFields/dfs:dataFields/tns:GetVendorsResponse/tns:GetVendorsResult/NewDataSet/Vendor s[Name='" + payeeTypedName + "']", NamespaceManager);

I'm writing to the event viewer so I can confirm that the code is actually hit. The form is Administrator approved and has Full Trust.

Any ideas on what could be causing this issue?

Thanks

4

2 回答 2

0

验证您的节点路径。("/dfs:myFields/dfs:dataFields/tns:GetVendorsResponse/tns:GetVendorsResult/) 路径的第一部分在一个命名空间中(dfs:),另一部分在另一个命名空间中(tns :). 你可以做两件事

1.使用您的网络服务设置 tns: 的名称空间

 IXMLDOMDocument2 domXml = (IXMLDOMDocument2)xDocument.DataObjects[dataSource].DOM;
            string selectionNamespaceValue = string.Empty;
   public const string SELECTION_NAMESPACE_VALUE =
        "xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:ns1='{0}'";

                selectionNamespaceValue = string.Format(CultureInfo.CurrentCulture, Constants.SELECTION_NAMESPACE_VALUE,Constants.DEFAULT_WEB_SERVICE);
 domXml.setProperty("SelectionNamespaces", selectionNamespaceValue);
  1. 您可以像这样访问节点。

    payeeDS.SelectSingleNode("/dfs:myFields/dfs:dataFields)..firstChild.firstChild;

于 2012-04-23T05:55:33.530 回答
0

XPathNavigator 的行为不会因环境而改变。我不确定,但你可能有两个问题之一。

payeeDS 没有作为有效的 XML 文件加载并且无法读取,或者更有可能是,

Sharepoint 在 XML 文件中添加了一些 NameSpacing,您需要更改导航。

于 2012-02-08T21:15:39.877 回答