3

I am creating an application in .NET Core that will handle some XML files.

In .NET 4.6 I have the following code:

var document = new XmlDocument(xml);
var node = document.SelectSingleNode("/SOMEPATH");
var value = node.GetValue("//SOMEOTHERPATH");

Apparently SelectSingleNode and GetValue don't exist in System.XML anymore.

What would be the equivalent functions in .NET Core?

AndreFeijo
  • 10,044
  • 7
  • 34
  • 64
  • http://stackoverflow.com/questions/35089399/selectsinglenode-is-giving-compilation-error-in-dnx-core-5-0 – sbrk Apr 05 '17 at 08:16

1 Answers1

7

https://github.com/dotnet/corefx/issues/17349

.Net Core 1.0 and .Net Standard 1.3 have SelectSingleNode as an extension method in the System.Xml.XPath.XmlDocument package (the page does not list .Net Standard 1.3, but the package is supported on it), so you will need to add a reference to that package to use it.

.Net Core 2.0 and .Net Standard 2.0 change it back to an instance method.

It appears the Value of an XmlNode can be accessed via XmlNode.Value.