Open In App

JQuery | isXMLDoc() Method

Last Updated : 30 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
This isXMLDoc() Method in jQuery is used to check to see if a DOM node is within an XML document. Syntax:
jQuery.isXMLDoc( node )
Parameters: This method accept a single parameter which is mentioned above and described below:
  • node: This parameter holds the DOM node that will be checked to see if it's in an XML document.
Return Value: It returns the boolean value. Below examples illustrate the use of isXMLDoc() method in jQuery: Example 1: html
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>JQuery | isXMLDoc() method</title>
    <script src=
"https://code.jquery.com/jquery-3.4.1.js">
    </script>

</head>

<body style="text-align:center;">

    <h1 style="color: green"> 
        GeeksforGeeks 
    </h1>

    <h3>JQuery | isXMLDoc() method</h3>
    <b>Value Return by isXMLDoc : </b>
    <br>
    <b id="geek">
    </b>

    <script>
        var str = "A computer science portal for geeks",
            html = jQuery.parseHTML(str);

        document.getElementById("geek").innerHTML = 
          jQuery.isXMLDoc(html);
    </script>
</body>

</html>                                       
Output: Example 2: html
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>JQuery | isXMLDoc() method</title>
    <script src=
"https://code.jquery.com/jquery-3.4.1.js">
    </script>

</head>

<body style="text-align:center;">

    <h1 style="color: green"> 
        GeeksforGeeks 
    </h1>

    <h3>JQuery | isXMLDoc() method</h3>
    <br>
    <b>Value Return By isXMLDoc :</b>
    <br>
    <b id="geek">
    </b>

    <script>
        var xml = "<rss version='2.0'>"+
                   "<channel>"+
                     "<body>String : parseXML</body>"+
                   "</channel>"+
                  "</rss>",
            xmlDoc = $.parseXML(xml);

        document.getElementById("geek").innerHTML = 
          jQuery.isXMLDoc(xmlDoc);
    </script>
</body>

</html>                    
Output:

Next Article

Similar Reads