Pass a DOM node; branch when it belongs to an XML tree.
Start with a DOM node (page node, AJAX XML node, or parsed XML).
Call $.isXMLDoc(node) — true means XML context.
If you only have a string, parse first with $.parseXML.
Branch your logic (selectors, namespaces, feed handling) for HTML vs XML.
Piece
Required?
Role
node
Yes
DOM node (or document) to test
Return
—
Boolean — XML document / XML node?
Common partner
—
$.parseXML() to create XML nodes
Pseudocode
Pseudocode
function isXMLDoc(node):
// true if node is an XMLDocument
// or lives inside an XMLDocument
return node belongs to XML (not HTML)
// Typical flow:
xmlDoc = $.parseXML(rssString)
if $.isXMLDoc(xmlDoc):
title = $(xmlDoc).find("title").text()
else:
// treat as HTML / reject
Reference
Cheat Sheet
Keep these facts handy while detecting XML nodes with jQuery.
Helper.describe turns the boolean into a short label.
HTML path. Page body → "HTML context".
XML path. Parsed document → "XML context".
Plugin use. Same pattern for feed handlers vs page DOM helpers.
Edge Cases & Pitfalls
Check these before relying on $.isXMLDoc() with real feeds.
html
Page nodes are almost always false
If you pass document or elements from the current page, expect false. That matches the official API examples.
string
Strings are not nodes
Do not pass raw XML text. Parse with $.parseXML first, then test the document or a found element.
jquery
Unwrap jQuery collections
Pass a native node: $el[0] or $el.get(0). A jQuery object itself is not a DOM node.
errors
Malformed XML may still be a document
Browsers often return a document with a parsererror node. Check parse errors after parseXML before trusting results.
Compatibility
Browser Support
jQuery.isXMLDoc() is available since jQuery 1.1.4+ in all modern browsers with jQuery loaded. It needs a browser DOM (not Node.js without a DOM polyfill).
✓ jQuery 1.1.4+ · Stable
jQuery.isXMLDoc()
Works in Chrome, Firefox, Safari, and Edge whenever jQuery is loaded. Pair with $.parseXML() for XML trees. Browser DOM required.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
$.isXMLDoc()jQuery 1.1.4+
Bottom line: Use $.isXMLDoc(node) in the browser with jQuery. Create XML nodes with $.parseXML; expect false for normal HTML page nodes.
Analysis
Performance Notes
Approach
Cost
Best for
$.isXMLDoc(node)
O(1)
HTML vs XML branching
$.parseXML(str)
O(n) in string size
Create XML once, then test/query
Re-parse the same string
Wasteful
Avoid — parse once, reuse the document
The boolean check is cheap. Parsing dominates cost — parse once, then call isXMLDoc / .find() on the same document.
One line: use $.isXMLDoc to tell HTML page nodes from XML trees — usually after $.parseXML.
Frequently Asked Questions
jQuery.isXMLDoc(node) returns true when node is an XML document or a DOM node inside an XML document. It returns false for nodes on a normal HTML page — including document and document.body.
Normal web pages use an HTML document whose root is <html>. The official jQuery API shows both document and document.body return false. Use isXMLDoc for XML contexts — RSS, AJAX XML, or strings parsed with $.parseXML().
Yes. After $.parseXML("<root/>"), the returned XMLDocument and its child elements return true from $.isXMLDoc(). That is the usual way beginners create XML nodes in jQuery.
Both HTML and XML nodes often look like objects. isXMLDoc checks whether the node belongs to an XML document — a specialized DOM check, not a generic type string.
Pass a real DOM node (or document). Prefer validating the value first. Falsy or non-node input is not useful and may behave differently across older jQuery builds.
When the same helper must branch between HTML page nodes and XML trees — for example choosing selectors, namespaces, or how to read text from feed items.