jQuery.parseXML()

Parses a string into an XML document.

jQuery.parseXML(data)🡢 XMLDocument

data Stringa well-formed XML string to be parsed

jQuery.parseXML uses the native parsing function of the browser to create a valid XML Document. This document can then be passed to jQuery to create a typical jQuery object that can be traversed and manipulated.

Create a jQuery object using an XML string and obtain the value of the title node.

JS
<p id="someElement"></p>
<p id="anotherElement"></p>
HTML
var xml =
    "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>",
  xmlDoc = $.parseXML(xml),
  $xml = $(xmlDoc),
  $title = $xml.find("title");

// Append "RSS Title" to #someElement
$("#someElement").append($title.text());

// Change the title to "XML Title"
$title.text("XML Title");

// Append "XML Title" to #anotherElement
$("#anotherElement").append($title.text());
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)