I have a table in MySQL that has one field defined as TEXT. The information is fed to the database by a webform using a textarea.
I'm using the following script to generate an XML with the information of the table:
#!/usr/bin/perl
use strict;
use DBI;
use XML::Generator::DBI;
use XML::Handler::YAWriter;
my $dbh = DBI->connect ("DBI:access info goes here",
{ RaiseError => 1, PrintError => 0});
my $out = XML::Handler::YAWriter->new (AsFile => "-", Encoding=>"ISO-8859-1");
my $gen = XML::Generator::DBI->new (
Handler => $out,
dbh => $dbh
);
$gen->execute ("SELECT text FROM table");
$dbh->disconnect ();
The problem is that when the text entered has breaklines it generates a malformed XML:
<text {http://axkit.org/NS/xml-generator-dbi}encoding="HASH(0x9c43ba0)">PHA+YWlqZHNvaWFqZG9pYXNqZG9pYXNqb2RpanNhaW9kanNhb2lkYXNvaWo8L3A+DQo8cD5zPC9w
Pg0KPHA+ZDwvcD4NCjxwPmFzPC9wPg0KPHA+ZHNhPC9wPg0KPHA+ZDwvcD4NCjxwPnNhZHNhZHNh
ZHM8L3A+DQo8cD4mbmJzcDs8L3A+DQo8cD5hc2Rhc2Rzc2FkZHNkc2FzZHNhPC9wPg0KPHA+Jm5i
c3A7PC9wPg0KPHA+YXNkZHNhZHNhYXNkc2Rhc2RhYXNkPC9wPg==
</text>
For example if the text entered is:
<p>One</p>
<p>Two</p>
It outputs the malformed XML, but when the text is:
<p>One</p> <p>Two</p>
It prints out the XML correctly.
Is there any way to 'strip' the breakline from the textarea or ignore it in the creation of the XML?
Thanks.