Question: Is it possible with Javascript (or jQuery to make example easier) get boolean variable from some field in XML?
If so - how it should be written in XML and what actions should be made on client side?

Please check the following code:

```
$(document).ready(function(){
    var data = "<?xml version='1.0' encoding='utf-8' ?><data><event id='2'><text><![CDATA[Hello there]]></text><bool1>true</bool1><bool2>false</bool2></event></data>";
    var xmlDoc = $.parseXML(data);
    var $xml = $(xmlDoc);
    var bool = data.find("bool1").text(); // "true" - string
});

```

What I would like here is to get string for the 'test' field and boolean for 'bool1'/'bool2'.

Thank you.

**Update:** So one either have to set up XML scheme or simply make direct comparisons ( === 'false' / === 'true' ) and convert that way to boolean.

Answer: 
Compare the read in text to the string "true", and assign the results of that comparison into your variable.

```
var b = data.find("bool1").text() === 'true';

```

In case of an extra whitespace in the text node, you could use jQuery to trim the read in text:

```
var b = $.trim(data.find("bool1").text()) === 'true';

```

If the node holds the text "true" (with some possible surrounding whitespace), then the variable will receive the boolean value of `true`. If the node holds ANY value other than the string "true", the variable will receive the boolean value of `false`.
In jQuery you can just wrap your XML string in a jQuery object to parse it:

```
$(document).ready(function(){
    var $data = $("<?xml version='1.0' encoding='utf-8' ?><data><event id='2'><text><![CDATA[Hello there]]></text><bool1>true</bool1><bool2>false</bool2></event></data>");
    var bool = $data.find("bool1").text(); // "true" - string
});

```

Then to force a variable to be Boolean you can set it's value with a conditional statement like this:

```
var bool = ($data.find("bool1").text() == 'false') ? false : true;

```