Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:09:27+00:00 2026-05-29T09:09:27+00:00

Is it possible with Javascript (or jQuery to make example easier) get boolean variable

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:09:28+00:00Added an answer on May 29, 2026 at 9:09 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible to make a jquery/javascript call like <span onclick=$('#dialog-2').html($.get('http://url.com');>Info</span> direct from html
Is it possible to get the top position of an element using javascript/jquery ?
Is it possible to make scrolling clouds with Flash, jQuery or JavaScript? If yes,
Is it possible to convert html tags to html entities using javascript/jquery using any
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system
Is it possible to implement long press in JavaScript (or jQuery)? How? (source: androinica.com
I wonder if it's possible to load jQuery within Opera User JavaScript , so
i need script in jquery / javascript that make the specific site as the
Possible Duplicate: javascript (jquery) calendar plugin I am going to develop the weekly calendar
Possible Duplicate: How do I check a checkbox with JQuery or Javascript? I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.