Closed martin-honnen closed 5 years ago
When I fix the method XPath2Select
to use the passed in arg
public static XPath2NodeIterator XPath2Select(this XPathNavigator nav, XPath2Expression expr, object arg)
{
return XPath2NodeIterator.Create(XPath2Evaluate(nav, expr, arg));
}
I don't longer get the exception.
Also wrote a test case
[Fact]
public void XPath2_XPath2Select_Variable()
{
var nav = GetOrders().CreateNavigator();
var nodeIt = nav.XPath2Select("//item[@quantity = $q]", new { q = 1 });
Assert.Equal(5, nodeIt.Count);
}
Fixed. New NuGet will be released today.
I am struggling to use a variable in XPath 2 with the
XPath2Select
method of anXPathNavigator
taking a second argument which I thought should be an anonymous object with variable values.When I used
foreach (XPathNavigator item in doc.CreateNavigator().XPath2Select("root/list/item[foo = $v]", new { v = "test" }))
I get an exceptionShouldn't that
arg
argument onXPathNavigatorExtensions.XPath2Select
bind that variable?Using XPath2 1.0.6.1 from NuGet.