I've just started with Scala, so please bear with my newbie question. :) I'm exploring the wonderful powers of XML support in Scala, and came to a task: I have an XML document with a node containing a boolean-like value: <bool_node>true</bool_node>
. I also have a case class with a boolean field in it. What I want to achieve is to create an instance of that class from the XML.
The problem, obviously, is that for XML <bool_node>
contains just a string, not boolean. What is the best way to handle this situation? Just try to convert that string to boolean using myString.toBoolean
? Or some other approach could is better?
Thanks in advance!