S
Steve
I've run across an issue that I'm trying to work around. I take that
back, I have a work around but I'm looking to see if anyone has a fix
for it.
The issue is that when loading a Boolean into a dataset using ReadXml,
..NET requires the "true" or "false" to be all lower case or 1 and 0. If
you use "True" or have any character capitalized, you get a
System.FormatException saying, "The string was not recognized as a
valid Boolean value."
The issue I have is that sometimes the XML is edited manually. I can't
guarantee that the person editing it won't unintentionally put "True".
I have a simple work around, I just catch the exception, find and
replace in the file and call ReadXml again but I'm looking to see if a
fix exist out there for it.
Here is some sample code.
Dataset1 ds = new Dataset1();
try
{
ds.ReadXml(@"C:\Test.xml");
}
catch (System.FormatException eFormat)
{
string temp = eFormat.Message;
}
<?xml version="1.0" standalone="yes"?>
<Dataset1 xmlns="http://tempuri.org/Dataset1.xsd">
<Table1>
<TestString>Blah</TestString>
<TestBool>True</TestBool>
</Table1>
<Table1>
<TestString>Blah2</TestString>
<TestBool>false</TestBool>
</Table1>
</Dataset1>
back, I have a work around but I'm looking to see if anyone has a fix
for it.
The issue is that when loading a Boolean into a dataset using ReadXml,
..NET requires the "true" or "false" to be all lower case or 1 and 0. If
you use "True" or have any character capitalized, you get a
System.FormatException saying, "The string was not recognized as a
valid Boolean value."
The issue I have is that sometimes the XML is edited manually. I can't
guarantee that the person editing it won't unintentionally put "True".
I have a simple work around, I just catch the exception, find and
replace in the file and call ReadXml again but I'm looking to see if a
fix exist out there for it.
Here is some sample code.
Dataset1 ds = new Dataset1();
try
{
ds.ReadXml(@"C:\Test.xml");
}
catch (System.FormatException eFormat)
{
string temp = eFormat.Message;
}
<?xml version="1.0" standalone="yes"?>
<Dataset1 xmlns="http://tempuri.org/Dataset1.xsd">
<Table1>
<TestString>Blah</TestString>
<TestBool>True</TestBool>
</Table1>
<Table1>
<TestString>Blah2</TestString>
<TestBool>false</TestBool>
</Table1>
</Dataset1>