gpt4 book ai didi

windows-phone-7 - HtmlAgilityPack XPath 无效 token

转载 作者:行者123 更新时间:2023-12-03 15:41:48 24 4
gpt4 key购买 nike

偶尔会看到无效的 token 异常。并非每次都抛出异常,并且 XPath 是静态的。不知道发生了什么。

doc.DocumentNode.SelectSingleNode("//*[contains(@itemprop,'softwareVersion')]");

.
Message:

'//*[contains(@itemprop,'softwareVersion')]' has an invalid token.


StackTrace:

at MS.Internal.Xml.XPath.XPathParser.CheckToken(LexKind t)
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.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 System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Select(String xpath)
at HtmlAgilityPack.HtmlNode.SelectSingleNode(String xpath)

我有时也为此看到它,具有相同的无效 token 异常
doc.DocumentNode.SelectNodes("//*[contains(@class,'item')]");

最佳答案

尝试不带 "*":
doc.DocumentNode.SelectSingleNode("//[contains(@itemprop,'softwareVersion')]");

关于windows-phone-7 - HtmlAgilityPack XPath 无效 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21839983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com