Megrez7
Megrez7

Reputation: 1457

Does .Net Core 3.1 and .Net 5.0 support XPath 2.0?

I am trying to XPathNavigator.SelectSingleNode without namespaces.

The initial version with namespaces string Val1 = nav.SelectSingleNode("/nn:AAA/nn:SomeTag/@Code", nsmgr).Value; works fine.

Options for getting rid of namespaces I am trying:

string Val2 = nav.SelectSingleNode("/*[local-name()='AAA']/*[local-name()='SomeTag']/@Code", nsmgr).Value;
string Val3 = nav.SelectSingleNode("/*:AAA/*:SomeTag/@Code", nsmg).Value;
string Val4 = nav.SelectSingleNode("/*:AAA/*:SomeTag/@Code").Value;

Val2 works as uses XPath 1.0 function. However both Val3 and Val4 throw an exception "Invalid token".

Wildcard shall be accepted, as documentation https://learn.microsoft.com/en-us/dotnet/api/system.xml.xpath?view=netcore-3.1 says it supports XPath 2.0 Data Model.

Same say answers to the question Is it possible to ignore namespaces in c# when using xPath?

Upvotes: 1

Views: 1327

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

They might support the XPath 2.0 data model, but I'm pretty certain they don't support XPath 2.0 syntax or the XPath 2.0 function library.

There's information on XPath 2.0 support for .NET at XPath and XSLT 2.0 for .NET?

The current Saxon product for .NET doesn't work on .NET 5.0, unfortunately. We're hoping to have a new product that fills that gap within weeks.

2023 Update

SaxonCS from v11.0 onwards works on .NET Core (that is, 5.0 or later)

Upvotes: 3

Related Questions