I'm getting an HIERARCHY_REQUEST_ERR (3) in IE9 only when I try to add an element from one document to the other. I'm creating my document as follows:
var xmlDoc = document.implementation.createDocument("","root",null);
and trying to add to it as follows:
$(otherDoc).find("selector_for_nodes_I_want").each(function(){
$(xmlDoc).find("root").append($(this).remove());
});
Firefox, and Chrome are fine with this, but IE9 doesn't like it. The idea is that xmlDoc is a filtered version of the otherDoc, which I will store as a string in sessionStorage. I'm hoping to save XMLHTTPRequests this way. I'm not too keen on the option of converting otherDoc to a string first, then converting back via $.parseXML(). I'm hoping for a better option, or if I'm thinking about this all wrong, I'd hear that argument as well. Thanks.
In lieu of an answer for the OP, is there anyone with a decent explanation as to why it is necessary to use domParser()
or $.parseXML(jqXHR.responseText)
when the response header is xml already: Content-Type:text/xml; charset=utf-8
. Why does IE9 guess that I want to use this ridiculous IXMLDOMDocument2
implementation to parse my response?