问题
According to MSDN, Extensions class in System.Xml.XPath should be available for Universal Windows Platform (Windows 10):
https://msdn.microsoft.com/en-us/library/system.xml.xpath.extensions(v=vs.110).aspx
However in default configuration not even the System.Xml.XPath namespace is available. The compiler and IntelliSense doesn't find it and even Resharper is unable to find the missing reference - although according to MSDN it should be in System.Xml.Linq.dll. (I can use LINQ without any problem)
Also in the reference manager I was unable to find a fitting assembly.
With some research I've found this official System.Xml.XPath package on NuGet: https://www.nuget.org/packages/System.Xml.XPath/
However this does not contain the Extension class (and thus the XPathSelectElement extension method) either. (But at least the other XPath classes)
Am I doing something wrong or this is an error in the documentation and none of these classes are available for Windows 10?
Edit: Things I've already done:
- Visual Studio restart
- Windows restart
- Test on a different computer
回答1:
So, it turned out that you have to add the System.Xml.XPath.XDocument Package with Nuget. It is a bit unfortunate that this is so undocumented on MSDN.
Credit goes to winffee on MSDN Social: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/46cc17ce-b562-4089-be9c-dd5aa53b36de/systemxmlxpath-in-universal-windows-platform?forum=wpdevelop
回答2:
You'll need to get the System.Xml.XPath
Nuget package (as you referenced in your question):
This will add the assembly and the proper refernce, and then add the proper using
declaration (needs to be there in addition to System.Xml.Linq
):
using System.Xml.XPath;
This will also allow for XPathSelectElement
(not depicted, but working in my environment).
来源:https://stackoverflow.com/questions/34797606/system-xml-xpath-in-universal-windows-platform