Xpath错误:“表达式必须求值为节点集”。 [英] Xpath error : "Expression must evaluate to a node-set."
问题描述
大家好,
我的代码是,
XPathNodeIterator xDomNodesDeliverables = this.DataSources [" Tdetails"]。CreateNavigator()。select(" / dfs:myFields / dfs:dataFields / d:SharePointListItem_RW [d:TID =" + tid +" ;和d:EmpNo =" + empno +"]",
this.NamespaceManager);
XPathNodeIterator xDomNodesDeliverables = this.DataSources["Tdetails"].CreateNavigator().Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:TID = " + tid+ " and d:EmpNo = " + empno+ "]", this.NamespaceManager);
当我在我的开发环境中运行代码时,我得到了以下错误;
when i run the code in my dev environment, i get the following error;
System.Xml.XPath.XPathException
表达式必须评估为节点集。
  ;在MS.Internal.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput,AxisType axisType,XPathNodeType nodeType)
在MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParsePredicate(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
在MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion)
在MS.Internal.Xml.XPath.QueryBuilder.Build(String query,Boolean allowVar,Boolean allowKey)
在MS.Internal.Xml.XPath.QueryBuilder.Build(String query,Boolean& needContext)
在System.Xml.XPath.XPathExpression.Compile(String xpath,IXmlNamespaceResolver nsResolver)
在System.Xml.XPath.XPathNavigator.Select(String xpath,IXmlNamespaceResolver resolver)
at New_Domestic_TR.FormCode.CTRL150_5_Clicked(Object sender,ClickedEventArgs e)
在Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
在Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
System.Xml.XPath.XPathException
Expression must evaluate to a node-set.
at MS.Internal.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput, AxisType axisType, XPathNodeType nodeType)
at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion)
at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar, Boolean allowKey)
at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean& needContext)
at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Select(String xpath, IXmlNamespaceResolver resolver)
at New_Domestic_TR.FormCode.CTRL150_5_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
相同的代码在我的测试环境中运行良好,但在我的开发环境中抛出错误。请帮我解决问题。
The same code works well in my test environment ,but throwing error in my dev environment.Kindly help me resolve the issue.
谢谢,
jovitech
推荐答案
检查xpath,它的条件是否结束,可能是原因。
check the xpath, it's ending on condition, that might be the reason.
这篇关于Xpath错误:“表达式必须求值为节点集”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!