【问题标题】:Does .Net Core 3.1 and .Net 5.0 support XPath 2.0?.Net Core 3.1 和 .Net 5.0 是否支持 XPath 2.0?
【发布时间】:2021-11-06 13:19:49
【问题描述】:

我正在尝试没有命名空间的 XPathNavigator.SelectSingleNode。

带有命名空间的初始版本 string Val1 = nav.SelectSingleNode("/nn:AAA/nn:SomeTag/@Code", nsmgr).Value; 工作正常。

我正在尝试摆脱命名空间的选项:

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 使用 XPath 1.0 函数。然而Val3Val4 都抛出异常“Invalid token”。

应接受通配符,因为文档 https://docs.microsoft.com/en-us/dotnet/api/system.xml.xpath?view=netcore-3.1 表示它支持 XPath 2.0 数据模型。

同样回答问题Is it possible to ignore namespaces in c# when using xPath?

【问题讨论】:

    标签: c# xml xpath .net-core


    【解决方案1】:

    它们可能支持 XPath 2.0 数据模型,但我很确定它们不支持 XPath 2.0 语法或 XPath 2.0 函数库。

    XPath and XSLT 2.0 for .NET? 有关于 XPath 2.0 对 .NET 的支持的信息

    不幸的是,当前用于 .NET 的 Saxon 产品不适用于 .NET 5.0。我们希望能在几周内推出一款新产品来填补这一空白。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-24
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 2018-02-14
      • 2017-08-24
      相关资源
      最近更新 更多