You are here: Reference > JavaScript > client-side > xml handling > properties > booleanValue (XPathResult)

booleanValue property (XPathResult)

Browser support:
If the type of the result represented by the XPathResult object is Boolean, returns the value of the result.
The XPathResult object represents the result of the evaluate method.
The type of the result depends on the fourth parameter of the evaluate method, or, if its value is ANY_TYPE, on the expression specified by the first parameter. With the resultType property the type of the result can be retrieved. If the value of the resultType property is Boolean_TYPE, then the BooleanValue property retrieves the value of the result as a Boolean, else the use of the BooleanValue property raises an exception.

Syntax:

object.booleanValue;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Boolean that retrieves the value represented by the current XPathResult object.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the BooleanValue property:
<head>
    <script type="text/javascript">
        function IsThereButton () {
            if (document.evaluate) {    // Firefox, Opera, Google Chrome and Safari
                var xPathRes = document.evaluate ( 'not(//BUTTON)', document, null, XPathResult.ANY_TYPE, null);
                var ret = (xPathRes.BooleanValue)? "does not contain any" : "contains at least one";
                alert ("This document " + ret + " BUTTON element.");
            }
            else {  // Internet Explorer
                alert ("Your browser does not support the evaluate method!");
            }
        }
    </script>
</head>
<body>
    <button onclick="IsThereButton ()">Is there a button within the document?</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content