No such interface supported

If you encounter the error message ‘No such interface supported’ when attempting to append nodes to an existing DOM on Internet Explorer then you may be encountering a restriction in IE which disallows appending nodes from one document to another. In my case I was attempting to append nodes from an XML document retrieved via XMLHttpRequest into a hidden div element on my page. Normally this works just fine, if XMLHttpRequest decides the response is an XML payload and populates the responseXML property with a DOM tree you can easily append into your page document. However if the content-type of the response is other than a type XMLHttpRequest determines to be XML then you need to construct and parse an XML document from the responseText field manually. IE’s XMLHttpRequest is pretty strict about the content-types it treats as XML, basically text/xml or application/xml -for MSXML6.0 anything ending in +xml should also work, doesn’t work for application;atom+xml;type=feed as far as I can tell, but then I guess that doesn’t end in +xml :(.

If you construct an XML document by parsing a text string; say the responseText property of an XMLHTTPRequest, then IE will consider that an entirely distinct document from the document of the page which initiated the XMLHttpRequest and hence you won’t be able to append the nodes from the parsed XML into the page’s document.

Workarounds include

  • rather than parsing the xml content via an XML parser, just stick the responseText inside a div in the page’s document by setting the innerHTML property, but if the data is actually XML then be prepared for pain as the page document is a HTML DOM not an XHTML DOM and xml specific data such as namespace data will be lost.
  • you could use XML data islands, although these are really an IE specific feature (Firefox supports them as well, but not other browsers AFAIK)
  • ask yourself if you really need to add the data to the page’s DOM, will it be displayed to the user ? if not then could it be stored in a JavaScript variable instead ?
Ⓗ Home   Ⓑ Blog   Ⓐ About