">

" />
Easy Tutorial
❮ Traversing Not Jq Sel Id ❯

jQuery.parseXML() Method

jQuery Miscellaneous Methods

Example

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

<p id="someElement"></p>
<p id="anotherElement"></p>
<script>
$(function () { 
    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() );
})
</script>

Definition and Usage

The $.parseXML() function is used to parse a string into the corresponding XML document.

Tip: This function uses the browser's built-in parsing function to create a valid XML document, which can then be passed into the jQuery() function to create a typical jQuery object for traversal or other operations.

Syntax

Parameter Description
xmlString String type, a well-formed string to be parsed into the corresponding XML document.

jQuery Miscellaneous Methods

❮ Traversing Not Jq Sel Id ❯