jQuery Find() and XML does not work in IE
<p>I am trying to use jQuery to parse an in-memory XML document. This works great in everything but IE (shocker). Some googling revealed that the problem is most likely due to the fact that IE is treating my document as HTML rather than XML MIME Type. </p>

<p>Is there a way to make my jQuery implmentation work or do I have to check the client browser and implement IE specific XML parsing?</p>

<p>Thanks!!</p>

<pre><code>function getQAData(xmlData) {
var dataArr = new Array();
$(xmlData).find('item').each(function() {
    dataArr.push({ questionid: $(this).attr("cellID"), answer: $(this).find('answer').text() });
});

return dataArr; // this array is nice and populated in everything but ie
</code></pre>

<p>XML Sample</p>

<pre><code>    &lt;hwroot&gt;
    &lt;data pid=""&gt;
        &lt;item cellID="24_951"&gt;
            &lt;question&gt;Are you there?&lt;/question&gt;
            &lt;answer&gt;No&lt;/answer&gt;
        &lt;/item&gt;
        &lt;item cellID="24_957"&gt;
            &lt;question&gt;A Question?&lt;/question&gt;
            &lt;answer&gt;blah blah blah&lt;/answer&gt;
        &lt;/item&gt;
&lt;/data&gt;
&lt;/hwroot&gt;
</code></pre>

<p><strong>Solution:</strong></p>

<p>My jQuery .find() solution will not work for reasons described by @treeface below. Here is my solution:</p>

<p>Branch JS code based on navigator :(</p>

<pre><code>  if (browserName == "Microsoft Internet Explorer") {
    MsXmlParse(xmlData, dataArr);

} else {
    $(xmlData).find('item').each(function() {
        dataArr.push({ questionid: $(this).attr("cellID"), answer: $(this).find('answer').text() });
    });
}
</code></pre>

<p>Definition of MsXmlParse</p>

<pre><code>function MsXmlParse(xmlDocument, qarray) {
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = "false";
xmldoc.loadXML(xmlDocument);

var itemElements = xmldoc.getElementsByTagName("item");

for (var i = 0; i &lt; itemElements.length; i++) {
    var questionCellID = itemElements[i].getAttributeNode("cellID").nodeValue;
    var answerTxt = itemElements[i].childNodes[1].text;

    qarray.push({ questionid: questionCellID, answer: answerTxt });
}
</code></pre>

<p>} //end msxmlparse</p>
