jQuery parseXML() exmaple

jQuery parseXML() function is used to parses a string into an XML document.


jQuery.parseXML( data )
data - a well-formed XML string to be parsed


Create a jQuery object using an XML string and obtain the value of the title node.
<!doctype html>
<html lang="en">

    <meta charset="utf-8">
    <title>jQuery.parseXML demo</title>
    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>


    <p id="someElement"></p>
    <p id="anotherElement"></p>

        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

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

        // Append "XML Title" to #anotherElement


RSS Title

XML Title
Try it Yourself - Copy paste code in Online HTML Editor to see the result