Is it possible to coerce string values in xml to bool?
Posted
by Kugel
on Stack Overflow
See other posts from Stack Overflow
or by Kugel
Published on 2010-03-24T13:07:42Z
Indexed on
2010/03/24
13:23 UTC
Read the original article
Hit count: 311
Let's suppose I have xml like this one:
<Server Active="No">
<Url>http://some.url</Url>
</Server>
C# class looks like this:
public class Server
{
[XmlAttribute()]
public string Active { get; set; }
public string Url { get; set; }
}
Is it possible to change Active property to type bool
and have XmlSerializer coerce "Yes" "No" to bool values?
Edit: Xml is received, I cannot change it. So, in fact, i'm interested in deserialization only.
© Stack Overflow or respective owner