How can I represent, true/false as the Boolean and "true"/"false" the strings in XML?
Eg.
<problem>false</problem>
<problem>problem_name</problem>
Or is there a better way to do this?
How can I represent, true/false as the Boolean and "true"/"false" the strings in XML?
Eg.
<problem>false</problem>
<problem>problem_name</problem>
Or is there a better way to do this?
It is a common unwritten rule that says in xml as a boolean value we should use: 'true' and 'false'
You can look here for further information: http://www.w3.org/TR/xmlschema-2/#boolean
You want to distinguish between "real" booleans and the texts "true" and "false"?
Well - an attribute might help you - e.g. IsActive. For "text":
<problem>false</problem>
For booleans:
<problem IsActive="false"></problem>
If you use a schema to define an element's type as string, anything using that schema to interpret the element's content will correctly interpret false
as being a string.
If you're not using a schema, and processes have to guess at a piece of content's type based on its representation, then you're going to have problems. You have to provide processes with some way of disambiguation, e.g. an attribute that indicates the content's data type, or (shudder) enclosing ambiguous literal values in quotation marks, i.e. "false"
for the string and false
for the boolean. Any approach you take here will be non-standard and non-portable.