4

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.

3
  • 2
    As an aside, do you need to use XPath here? I'd personally just use LINQ to XML - no need to worry about whether withCode contains apostrophes, for example - but I appreciate you may have other requirements.
    – Jon Skeet
    Commented Jun 19, 2015 at 15:09
  • Basic Querys Linq to XML
    – MethodMan
    Commented Jun 19, 2015 at 15:13
  • No... Microsoft never implemented XPath 2.0 or Xslt 2.0. See for example stackoverflow.com/a/7521282/613130 of 2011. In one comment someone asked for an update in 2014...
    – xanatos
    Commented Jun 19, 2015 at 15:34

1 Answer 1

15

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.

2
  • 6
    This is incredibly disheartening that in 2018 XPath 1.0 is still the only supported version in .NET Commented Sep 26, 2018 at 14:59
  • Yeah and if you try that link now, you'll see that they've completely taken the User Voice down. There is no "User Voice".
    – Fütemire
    Commented Jan 21, 2020 at 21:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.