I’m currently looking for an easy way to extract information from server XML responses using JavaScript. jQuery seems like a good candidate for this.
When it comes to parsing XML with jQuery, I keep coming across code examples similar to the following snippet:
function parseXml(responseXml) {
$(responseXml).find('someSelector')...
}
Yet, the jQuery Core documentation (quotation below) clearly states that you aren’t supposed to do that:
jQuery( html, [ ownerDocument ] )
htmlA string of HTML to create on the fly. Note that this parses HTML, not XML.
This makes me wonder why so many online resources nevertheless suggest parsing XML via $(responseXml). Does this generally work without any problems, despite what the API documentation says? In what cases will parsing XML like this actually not work?
the jQuery ajax documentation adds http://api.jquery.com/jQuery.ajax/:
Also at http://api.jquery.com/jQuery/