jQuery.parseXML() method
Example
Create a jQuery object from an XML string and get the value of the title node.
<p id="someElement" p>
<p id="anotherElement" p>
<script$(function(){var xml=">
"
,
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
Try it »
Definition and Usage
The $.parseXML() function is used to parse a string into a corresponding XML document.
**Tip:** This function uses the browser's built-in parsing function to create a valid XML document, which can be passed to the jQuery() function to create a typical jQuery object for traversal or other operations.
Syntax
$
.parseXML( xmlString )
| Parameters | Description |
|---|---|
| xmlString | String type: A well-formed string to be parsed into the corresponding XML document. |
jQuery Miscellaneous Methods