Skip to main content

Bug Tracker

Side navigation

#12151 closed bug (invalid)

Opened July 26, 2012 01:57PM UTC

Closed September 05, 2012 09:00AM UTC

IE 10 jQuery.parseXML

Reported by: mattBate Owned by: mattBate
Priority: undecided Milestone: None
Component: unfiled Version: 1.8b2
Keywords: Cc:
Blocked by: Blocking:

When trying to parse xml in IE 10 jQuery uses the window.DOMParser method rather than the activeXObject method used in previous versions of IE.

This apears to work, however the object returned is not the same type and doesn't have the same set of methods as the domParser returns in Chrome and FF.

I think the logic needs to be reversed to test for the presence of ActiveX rather than testing for the presence of window.DOMParser.

Hope this makes sense.


Attachments (0)
Change History (7)

Changed July 26, 2012 02:02PM UTC by dmethvin comment:1

owner: → mattBate
status: newpending

Some related information regarding the effect on XHR:

Matt, can you provide some more detail about what is different, including a reference to pages?

Changed July 26, 2012 03:50PM UTC by mattBate comment:2

status: pendingnew

I would provide a jsFiddle for this but our network at work is so restricted that site doesn't work.

I'm trying to do something similar to this, where the XML has been scraped from the screen and is passed in to parse XML as a string.

The system i'm working on has various parts where the IE/other browsers split. but in IE 10 the returned Object from the XML has neither an evaluate or selectSingleNode method, it's a different object type again. A new third way!


var testingXML = jQuery.parseXML('<?xml version="1.0"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading></note>')

if (testingXML.evaluate) {
	// Non-IE
	var xmlnodes = testingXML.evaluate("//to", testingXML, null, XPathResult.ANY_TYPE, null);
	if (xmlnodes != null) {
		var node = xmlnodes.iterateNext();
		strRet = node.textContent;
else {
	// Internet Explorer
	var node = testingXML.selectSingleNode("//to");
	if (node != null)
		strRet = node.text; 


Changed July 26, 2012 05:39PM UTC by dmethvin comment:3

status: newpending

What I'm looking for is some indication that IE10 is doing something that contradicts a standard. This is DOMParser:

It returns a Document, in particular an XMLDocument for this case.

No .evaluate() or .selectSingleNode() there. And indeed the example doesn't work on IE9:

Are you just looking for a portable way to get the info?

Again, some links to controlling standards or an example of how it could be made better (or was recently made worse) would be helpful.

Changed August 08, 2012 01:33PM UTC by comment:4

I have run into this issue as well. Having missed the fact that the returned object has no .evaluate method, I tried extending the object prototype like so:

if (document.implementation.hasFeature("XPath", "3.0"))
	if (typeof XMLDocument == "undefined") { XMLDocument = Document; }
	XMLDocument.prototype.selectNodes = function (cXPathString, xNode)
		if (!xNode) { xNode = this; }
		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for (var i = 0; i < aItems.snapshotLength; i++) { aResult[i] = aItems.snapshotItem(i); }
		return aResult;
	XMLDocument.prototype.selectSingleNode = function (cXPathString, xNode)
		if (!xNode) { xNode = this; }
		var xItems = this.selectNodes(cXPathString, xNode);
		if (xItems.length > 0) { return xItems[0]; }
		else { return null; }
	Element.prototype.selectNodes = function (cXPathString)
		if (this.ownerDocument.selectNodes) { return this.ownerDocument.selectNodes(cXPathString, this); }
		else { throw "For XML Elements Only"; }
	Element.prototype.selectSingleNode = function (cXPathString)
		if (this.ownerDocument.selectSingleNode) { return this.ownerDocument.selectSingleNode(cXPathString, this); }
		else { throw "For XML Elements Only"; }

But it seems like the document implementation, does not have any XPath feature. But since it has no .evaluate, I instead override the parseXML of jQuery with one that will implement the ActiveX MSXML instead of using the DOMParser.

Changed August 13, 2012 09:05AM UTC by SeanH comment:5

I added comments to this ticket which I believe is related #4958.

Changed August 22, 2012 03:43AM UTC by GotDibbs comment:6

I believe IE9 and IE10 are both missing XPath support on Documents meaning that 'selectSingleNode', 'evaluate' and 'selectNodes' are all missing. The recommended approach given here: is to switch to querySelector or just fallback to the ActiveX object. I have personally fallen back on the ActiveX object as I've found the alternative to be too drastically different in order to implement with old browsers in mind.

Changed September 05, 2012 09:00AM UTC by trac-o-bot comment:7

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!