Similar to my last post on parsing a Date object, you can’t assign XML data directly to a Boolean object or the value will always end up being ‘true’. This is because the Boolean() constructor parses all non-null XML data as true.
Consider the following XML:
To get the data in the ‘valid’ attribute and assign it to a Boolean object, you’d do the following in your code:
Note that this will only work if the validString is all lowercase, so you may want to call toLowerCase() on validString just to be safe.