JQuery | parseXML() Method
This parseXML() Method in jQuery is used to parse a string into an XML document.
Syntax:
jQuery.parseXML( data )
Parameters: This method accept single parameter which is mentioned above and described below:
- data: This parameter holds the well-formed XML string to be parsedd.
Return Value: It returns the XML document.
Below exa,ples illustrate the parseXML() method in jQuery:
Example 1: In this example, the parseXML() method parses a string into an XML document.
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>JQuery | parseXML() method</title> <script src= </script> <style> #a { color: blue; } #b { color: red; } </style></head> <body style="text-align:center;"> <h1 style="color: green"> GeeksforGeeks </h1> <h3>JQuery | parseXML() method</h3> <p id="a"></p> <p id="b"></p> <script> var xml = "<rss version='2.0'>"+ "<channel>"+ "<body>String : parseXML</body>"+ "</channel>"+ "</rss>", xmlDoc = $.parseXML(xml), $xml = $(xmlDoc), $body = $xml.find("body"); $("#a").append($body.text()); $body.text("XMLDocument : parseXML"); $("#b").append($body.text()); </script></body> </html> |
Output:
Example 2: .
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>JQuery | parseXML() method</title> <script src= </script> <style> #a { color: blue; } #b { color: red; } </style></head> <body style="text-align:center;"> <h1 style="color: green"> GeeksforGeeks </h1> <h3>JQuery | parseXML() method</h3> <p id="a"></p> <p id="b"></p> <script> var xml = "<rss version='2.0'>"+ "<channel>"+ "<body style='text-align:center;'>"+ "<h1 style='color: green'>GeeksForGeeks</h1>"+ "<h3>JQuery | parseXML() method</h3>"+ "</body>"+ "</channel>"+ "</rss>", xmlDoc = $.parseXML(xml), $xml = $(xmlDoc), $val = $xml.find("h3"); $val.text("Parses a string into an XML document."); $("#a").append($val.text()); </script></body> </html> |
Output:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.


