jQuery.parseXML(data) (alias $.parseXML) parses a well-formed XML string into an XMLDocument using the browser’s native parser (added in jQuery 1.5). Wrap the result with $() to query it like a jQuery collection.
Syntax
Start with these common calls. Keep them short and readable.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
xmlDoc
Used in $(xmlDoc). jQuery wrapper for traversal
Return Value
Return Value
Description
Boolean
Often true or false depending on the match or state.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Parse RSS and Read title
Official jQuery API pattern in a few lines.
jQuery
var xml =
'<rss version="2.0"><channel><title>RSS Title</title></channel></rss>';
var xmlDoc = $.parseXML(xml);
var $title = $(xmlDoc).find("title");
console.log($title.text()); // "RSS Title"
Selector.item > title targets only item titles (not the channel title).
Each..each() visits every match and pushes .text() into an array.
Frequently Asked Questions
jQuery.parseXML(data) takes a well-formed XML string and returns an XMLDocument — the browser's native XML document. Wrap it with $(xmlDoc) to use .find(), .text(), and other jQuery traversal helpers on XML nodes.
The jQuery API parses an RSS snippet, wraps the XMLDocument with $(), finds the title element, reads "RSS Title", changes it to "XML Title" with .text(), and appends the text to the page.
parseHTML returns an array of HTML DOM nodes for HTML fragments. parseXML returns a full XMLDocument for well-formed XML. XML needs a single root, closed tags, and case-sensitive names — common for RSS, Atom, and SOAP.
Both use native browser XML parsing. $.parseXML() is a thin cross-browser wrapper (since jQuery 1.5). Modern code can use new DOMParser().parseFromString(str, "text/xml") directly; parseXML stays useful in jQuery codebases.
The browser often returns an XMLDocument with a parsererror node instead of throwing. Check for parsererror (or empty .find() results) before trusting the data — especially with external feeds.
After parsing, nodes belong to an XML document. jQuery.isXMLDoc() returns true for those nodes and false for normal HTML page nodes. Use it when code must branch between HTML and XML trees.
No. parseXML relies on the browser's native XML/DOM parser. It does not work in Node.js, Bun, or Deno unless you add a DOM polyfill. On the server, use an XML library instead.