Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Xml.XPath in Universal Windows Platform

Tags:

c#

.net

xml

xpath

uwp

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
like image 272
BotondF Avatar asked Jan 14 '16 19:01

BotondF


People also ask

What is XML XPath in XML?

Xml. XPath Namespace The System.Xml.XPath namespace contains the classes that define a cursor model for navigating and editing XML information items as instances of the XQuery 1.0 and XPath 2.0 Data Model. This class contains the LINQ to XML extension methods that enable you to evaluate XPath expressions.

What is XPath and why should I Care?

What is XPath anyway? Well, XPath is a query language that is used for selecting nodes from an XML document. In addition, I can use XPath to compute values, but this really does not have much to do with querying data from event logs.

What is XPath in event logs?

Well, XPath is a query language that is used for selecting nodes from an XML document. In addition, I can use XPath to compute values, but this really does not have much to do with querying data from event logs.

How to use XPath query in Windows PowerShell?

The easiest Xpath query is *, which means “return everything.” I can type this directly into the Windows PowerShell console as follows (remember that the FilterXPath parameter expects a string, and therefore, quotation marks are not required): On the other hand, if I put it in a script, I need to add the quotation marks, as shown here:


1 Answers

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

like image 128
BotondF Avatar answered Oct 05 '22 23:10

BotondF