System.Xml.XPath in Universal Windows Platform
Asked Answered
T

3

5

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
Tillfourd answered 14/1, 2016 at 19:0 Comment(0)
T
5

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

Tillfourd answered 15/1, 2016 at 9:0 Comment(0)
W
0

You'll need to get the System.Xml.XPath Nuget package (as you referenced in your question):

System.Xml.Linq reference manager screengrab

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;

sample XPathEval

This will also allow for XPathSelectElement (not depicted, but working in my environment).

Wingover answered 14/1, 2016 at 19:59 Comment(3)
This does not help - VS cannot find any System.Xml.Linq assembly targeting .NET for Windows Universal. You've probably tried it with a normal windows application. (I assume that because of the project name: ConsoleApplication1) But this is about Universal Windows Platform which is a somewhat restricted subset of the full .net framework. Anyways, thank you for your answer!Tillfourd
Are you sure, you've added only this package? Unfortunately this is not working for me...Tillfourd
Positive. This was done on an otherwise fresh install of Windows 10/VS 2015.Wingover
M
0

To enable XPath extensions in UWP applications you can add the following nuget package

System.Xml.XPath.XmlDocument => for XMLDocument processing

System.Xml.XPath.XDocument => for XDocument processing.

Matchbook answered 16/6, 2020 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.