When encountering this error message...
The occurrence of a ReferenceError where 'XPathEvaluator' is indicated as undefined
...it suggests that a ReferenceError happened during the process of XML manipulation in Javascript.
In his book Professional Javascript for Web Developers, @nzakas (Wrox Author) discussed the challenges with browsers not supporting the XPathEvaluator
. He recommended utilizing specific Document object methods to fill the gap left by those unsupported browsers.
Presently, only Internet Explorer does not provide support for XPathEvaluator
. For IE, using selectNode()
and selectSingleNode()
on the DOM Document object instead is recommended.
An Example Scenario
According to an article on Resolving the Error "XPathEvaluator’ is undefined", the script error stating XPathEvaluator is undefined
often arises in Microsoft Dynamics CRM 2011 following an upgrade to Internet Explorer 11. Investigation revealed that any HTML asset incorporating ClientGlobalContext.js
(used to access parent form context) will trigger the error message
SCRIPT5009: ‘XPathEvaluator’ is undefined
.
Possible Solution
A convenient fix would involve including the following line within the <head>
section of your custom HTML files referencing that specific JS file:
<meta http-equiv="X-UA-Compatible" content="IE=10" />
This particular line aims to compel the browser to operate the web resource in Internet Explorer 10 mode.
Important Note: It's crucial to highlight that this functionality may be phased out in Microsoft Edge, which serves as Microsoft’s recent replacement for Internet Explorer.