【问题标题】:System.Xml.XPath in Universal Windows Platform通用 Windows 平台中的 System.Xml.XPath
【发布时间】:2016-01-14 19:00:54
【问题描述】:

根据 MSDN,System.Xml.XPath 中的 Extensions 类应该可用于通用 Windows 平台(Windows 10):

https://msdn.microsoft.com/en-us/library/system.xml.xpath.extensions(v=vs.110).aspx

但是在默认配置中,甚至 System.Xml.XPath 命名空间都不可用。 编译器和 IntelliSense 没有找到它,甚至 Resharper 也无法找到丢失的参考 - 尽管根据 MSDN,它应该在 System.Xml.Linq.dll 中。 (我可以毫无问题地使用 LINQ)

在参考管理器中我也找不到合适的组件。

通过一些研究,我在 NuGet 上找到了这个官方 System.Xml.XPath 包: https://www.nuget.org/packages/System.Xml.XPath/

但是,它也不包含 Extension 类(因此也不包含 XPathSelectElement 扩展方法)。 (但至少是其他 XPath 类)

我是不是做错了什么,或者这是文档中的错误,并且这些类都不适用于 Windows 10?

编辑: 我已经做过的事情:

  • Visual Studio 重启
  • Windows 重新启动
  • 在另一台计算机上测试

【问题讨论】:

    标签: c# .net xml xpath uwp


    【解决方案1】:

    所以,事实证明您必须使用 Nuget 添加 System.Xml.XPath.XDocument 包。 不幸的是,这在 MSDN 上没有记录。

    归功于 MSDN Social 上的 winffee: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/46cc17ce-b562-4089-be9c-dd5aa53b36de/systemxmlxpath-in-universal-windows-platform?forum=wpdevelop

    【讨论】:

      【解决方案2】:

      您需要获得System.Xml.XPath Nuget 包(正如您在问题中提到的那样):

      这将添加程序集和正确的引用,然后添加正确的using 声明(除了System.Xml.Linq 还需要在那里):

      using System.Xml.XPath;
      

      这也将允许XPathSelectElement(未描述,但在我的环境中工作)。

      【讨论】:

      • 这无济于事 - VS 找不到任何针对 Windows Universal 的 .NET 的 System.Xml.Linq 程序集。您可能已经使用普通的 Windows 应用程序尝试过它。 (我假设是因为项目名称:ConsoleApplication1)但这是关于通用 Windows 平台,它是完整 .net 框架的一个受限制的子集。不管怎样,谢谢你的回答!
      • 你确定,你只添加了这个包吗?不幸的是,这对我不起作用......
      • 阳性。这是在 Windows 10/VS 2015 的全新安装上完成的。
      【解决方案3】:

      要在 UWP 应用程序中启用 XPath 扩展,您可以添加以下 nuget 包

      System.Xml.XPath.XmlDocument => 用于 XMLDocument 处理

      System.Xml.XPath.XDocument => 用于 XDocument 处理。

      【讨论】:

        猜你喜欢
        • 2016-11-06
        • 2016-01-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多