Почему .NET XPath не нравится [position () le 10001] - PullRequest
2 голосов
/ 28 июня 2011

Я передаю следующее в своем коде C # (.NET 3.5):

XPathNavigator.
    Compile(/windward-studios/Products/Product/@ProductID[position() le 10001])

и получаю:

System.Xml.XPath.XPathException произошла
Сообщение = '/ windward-studios / Products / Product / @ ProductID [position () le 10001]' имеет недопустимый токен.
Source = System.Xml StackTrace: в MS.Internal.Xml.XPath.XPathParser.CheckToken (LexKind t) в MS.Internal.Xml.XPath.XPathParser.ParsePredicate (AstNode qyInput) в MS.Internal.Xml.XPath.XPathParser.ParseStep (AstNode qyInput) в MS.Internal.Xml.XPathserPP.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.Parse(AstNode qyInput) по адресу MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr (AstNode qyInput) по адресу MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr (AstNode qyInput) по адресу MS.Internal.XExPr.qyInput) по адресу MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr (AstNode qyInput) по адресу MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr (AstNode qyInput) по адресу MS.Internal.Xml.XPath.ExParPlayer (XPath.XPar)по адресу MS.Internal.Xml.XPath.XPathParser.ParseOrExpr (AstNode qyInput) по адресу MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion (String xpathExpresion) по адресу MS.Internal.Xml.XPath.QueryBleanarBuilder., Boolean allowKey) в MS.Internal.Xml.XPath.QueryBuilder.Build (строковый запрос, Boolean & needContext) в System.Xml.XPath.XPathExpression.Compile (строковый xpath, IXmlNamespaceResolver nsResolverNS).(Строка xpath) в WindwardReportsDrivers.net.windward.datasource.xml.XPathDataSource.XPathDocNode.SelectNodes (XPathNavigator nav, String xpath, String sortXPath)
InnerException:

Есть идеи, почему?

спасибо - Дейв

1 Ответ

4 голосов
/ 28 июня 2011

Есть несколько проблем с вашим запросом:

  1. Это <=, а не le. Не забудьте экранировать <, если вы пишете это внутри XML.
  2. Вы пытаетесь применить [] к узлу атрибута - это, вероятно, не то, что вы хотите. Возможно, вы хотите ... /Product[position() le 10001]/@ProductID?
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...