{"id":1364,"date":"2010-10-21T14:16:55","date_gmt":"2010-10-21T12:16:55","guid":{"rendered":"https:\/\/www.peppercrew.nl\/?p=1364"},"modified":"2011-05-19T15:00:10","modified_gmt":"2011-05-19T14:00:10","slug":"true-is-not-true","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/true-is-not-true\/","title":{"rendered":"True is not true (?)"},"content":{"rendered":"<div><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2010\/10\/XP_Developer-VMware-Workstation_2010-10-21_14-04-541.png\"><\/a><\/div>\n<div><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2010\/10\/XP_Developer-VMware-Workstation_2010-10-21_14-04-541.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1365\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2010\/10\/XP_Developer-VMware-Workstation_2010-10-21_14-04-541.png\" alt=\"The string 'True' is not a valid Boolean value.\" width=\"654\" height=\"235\" \/><\/a><\/div>\n<div>This error is thrown when an XML file is read into a DataSet using &#8220;<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.boolean(VS.80).aspx\">System.Boolean<\/a>&#8221; as <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.data.datacolumn.datatype.aspx\">DataType<\/a>.<br \/>\n<!--more--><br \/>\nAfter a dataset is created, filled and written to an XML file using <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.data.dataset.writexml(VS.71).aspx\">.WriteXML<\/a> the content might look like this:<br \/>\n<code><br \/>\n<\/code><\/div>\n<blockquote>\n<div>&lt;Systems&gt;<br \/>\n&lt;GUID&gt;7f939d72-122e-4d9b-8bfb-3bfca94c813c&lt;\/GUID&gt;<br \/>\n&lt;Name&gt;LOCALHOST&lt;\/Name&gt;<br \/>\n&lt;IPv4&gt;127.0.0.1&lt;\/IPv4&gt;<br \/>\n&lt;Memory_Size&gt;0&lt;\/Memory_Size&gt;<br \/>\n&lt;IsDataCollector&gt;<strong>True<\/strong>&lt;\/IsDataCollector&gt;<br \/>\n&lt;IsLoadBot&gt;<strong>False<\/strong>&lt;\/IsLoadBot&gt;<br \/>\n&lt;DataCollector_TimeOut&gt;30&lt;\/DataCollector_TimeOut&gt;<br \/>\n&lt;LoadBot_SessionStreams&gt;0&lt;\/LoadBot_SessionStreams&gt;<br \/>\n&lt;LoadBot_Slots&gt;0&lt;\/LoadBot_Slots&gt;<br \/>\n&lt;WOL&gt;<strong>False<\/strong>&lt;\/WOL&gt;<br \/>\n&lt;\/Systems&gt;<br \/>\n&lt;Systems&gt;<br \/>\n&lt;GUID&gt;cc126325-2eb9-4547-b99b-4c73a36f357e&lt;\/GUID&gt;<br \/>\n&lt;Name&gt;LoadBot01&lt;\/Name&gt;<br \/>\n&lt;IPv4&gt;172.17.2.72&lt;\/IPv4&gt;<br \/>\n&lt;Memory_Size&gt;49152&lt;\/Memory_Size&gt;<br \/>\n&lt;OS_Family&gt;Windows 7&lt;\/OS_Family&gt;<br \/>\n&lt;IsDataCollector&gt;<strong>False<\/strong>&lt;\/IsDataCollector&gt;<br \/>\n&lt;IsLoadBot&gt;<strong>True<\/strong>&lt;\/IsLoadBot&gt;<br \/>\n&lt;DataCollector_TimeOut&gt;30&lt;\/DataCollector_TimeOut&gt;<br \/>\n&lt;LoadBot_SessionStreams&gt;5&lt;\/LoadBot_SessionStreams&gt;<br \/>\n&lt;LoadBot_Slots&gt;500&lt;\/LoadBot_Slots&gt;<br \/>\n&lt;GUID_RunAsAccount&gt;f96312d1-7973-4448-9509-34b15eb78848&lt;\/GUID_RunAsAccount&gt;<br \/>\n&lt;WOL&gt;<strong>False<\/strong>&lt;\/WOL&gt;<br \/>\n&lt;\/Systems&gt;<\/div>\n<\/blockquote>\n<div>As you can see, both &#8220;True&#8221; and &#8220;False&#8221; starts with a capitol letter. This is what causes the problem, the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/aa325639(VS.71).aspx\">.ReadXML<\/a> method expects &#8220;true&#8221; or &#8220;false&#8221; instead of &#8220;True&#8221; or &#8220;False&#8221;.<br \/>\nRemember, the content of the file is the result of the .WriteXML method, so is it a <a href=\"https:\/\/encyclopediadramatica.com\/Is_not_a_bug,_it's_a_feature\">bug or a feature<\/a>?<\/div>\n<div>I don&#8217;t know, but the &#8220;solution&#8221; to the problem is quite simple. After saving an XML file using the .WriteXML method replace &#8220;&gt;Truetrue&lt;&#8221; and do the same for False.<\/div>\n<div>I usually use this code to write an XML file:<\/div>\n<div><code><br \/>\nFriend Sub WriteXML(ByVal Source As DataSet, ByVal Filename As String)<br \/>\nTry<br \/>\n'Define variables<\/code><\/div>\n<p><code><\/p>\n<div>'Save dataset to XML<br \/>\nSource.WriteXml(Filename, XmlWriteMode.IgnoreSchema)<\/div>\n<div>'(re)open XML file<br \/>\nDim objFileStream As FileStream = New FileStream(Filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)<\/div>\n<div>'Create streams<br \/>\nDim streamReader As New StreamReader(objFileStream)<br \/>\nDim streamWriter As New StreamWriter(objFileStream)<\/div>\n<div>'Read content of file<br \/>\nDim strContentOfXMLFile As String = streamReader.ReadToEnd<\/div>\n<div>'Replace boolean values<br \/>\nstrContentOfXMLFile = strContentOfXMLFile.Replace(\"&gt;TruetrueFalsefalse&lt;\")<\/div>\n<div>'Reset position in filestream<br \/>\nobjFileStream.Position = 0<\/div>\n<div>'Reset lenght (in case content has changed)<br \/>\nobjFileStream.SetLength(strContentOfXMLFile.Length)<\/div>\n<div>'Write new content to XML file<br \/>\nstreamWriter.Write(strContentOfXMLFile)<br \/>\nstreamWriter.Flush()<br \/>\nstreamWriter.Close()<\/div>\n<div>'Close file<br \/>\nobjFileStream.Close()<br \/>\nCatch<br \/>\nEnd Try<br \/>\nEnd Sub<\/div>\n<p><\/code><\/p>\n<div>Ingmar Verheij<\/div>","protected":false},"excerpt":{"rendered":"<p>This error is thrown when an XML file is read into a DataSet using &#8220;System.Boolean&#8221; as DataType.<\/p>","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[312],"tags":[237,238,239,240,241,242],"class_list":["post-1364","post","type-post","status-publish","format-standard","hentry","category-vb-net-scripting","tag-net","tag-dataset","tag-readxml","tag-the-string-true-is-not-a-valid-boolean-value","tag-vb-net","tag-writexml"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=1364"}],"version-history":[{"count":4,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1364\/revisions"}],"predecessor-version":[{"id":2452,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1364\/revisions\/2452"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=1364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=1364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}