Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What version of XPath does XmlDocument.SelectSingleNode use?

Tags:

c#

.net

xml

xpath

I'm using the XmlDocument class like this:

divisionsDoc.SelectSingleNode(
    string.Format(@"Root/PoliticalDivisions/PoliticalDivision[upper-case(@Code)='{0}']", withCode.ToUpper()));

And this is resulting in the error:

Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

I gather this is due to the upper-case XPath function, which I understand exists in XPath 2.0 and not 1.0 (from here, here, etc.)

MSDN doesn't specify the version of XPath it uses. I'm targeting .NET 4.5.1 -- wouldn't that be late enough to be using XPath 2.0? Or is that something that is defined elsewhere (outside of .NET)?

How can I find out what version of XPath is being targeted?

Please note, I'm aware of the work-around using translate('some text','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') -- that's not what I'm asking.

like image 690
rory.ap Avatar asked Dec 15 '22 13:12

rory.ap


1 Answers

Microsoft never implemented XPath 2.0 or Xslt 2.0... See for example this uservoice (aptly named Native support for XPath 2.0 or XSLT 2.0 in .NET) of 2013...

Last comment of March 2015 by one user:

i guess we will never see this as the world doesn't like XML anymore, it's all about JSON. Which is a shame as XML is still far better for a number of key scenarios than JSON.

like image 195
xanatos Avatar answered Jan 01 '23 09:01

xanatos