Writing/Reading boolean field in XML

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rahucha
Posts: 24
Joined: Tue 18 Nov 2014 09:52

Writing/Reading boolean field in XML

Post by rahucha » Tue 18 Nov 2014 10:00

Hi,

I'm using the method "SaveToXML" in TMyQuery and the XML is created correctly. I have a table with a boolean field, so in the XML is generated as "yes" or "no", like:

<xml>
...
NameField="yes"
...

The problem is that at a later time, I'm loading the XML into a table via MySQL, using a SQL query as:

"LOAD XML LOCAL INFILE 'my_xml.xml' INTO TABLE MyTable...."

And it seems that the Boolean values are not loaded correctly. It seems that the above query requires in the XML the boolean fields as "1" or "0" (not "True" or "False"). If I manually change in the XML the strings "True" by "1" (and "False" by "0"), the boolean values are loaded correctly into the table.

Am I missing something or an extra parameter to set?

Thanks!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Writing/Reading boolean field in XML

Post by ViktorV » Tue 18 Nov 2014 14:03

To solve the problem, please set the TMyQuery.Options.EnableBoolean property to False before calling the TMyQuery.SaveToXML method.
You can find more details in the MyDAC help: http://www.devart.com/mydac/docs/index. ... oolean.htm

rahucha
Posts: 24
Joined: Tue 18 Nov 2014 09:52

Re: Writing/Reading boolean field in XML

Post by rahucha » Thu 20 Nov 2014 10:45

Thanks a lot! Really appreciated!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Writing/Reading boolean field in XML

Post by ViktorV » Fri 21 Nov 2014 09:21

It is good to see that the problem has been solved. Feel free to contact us if you have any further questions.

Post Reply