Hi, Thanks for the fast reply. For instance i use the following XML file:
<?xml version="1.0" encoding="UTF-8"?>
<log>
<logentry
revision="12345">
<author>someAuthor</author>
<date>2017-10-11T09:32:15.704935Z</date>
<msg>This is my SVN message with characters like ä or &.</msg>
</logentry>
</log>
After I execute the following script ...
use XML::Smart;
open(my $fh, "<", "test.xml") or die $!;
my $logString;
while (<$fh>)
{
$logString .= $_;
}
my $test = XML::Smart->new($logString);
$test->{log}->{logentry}[0]->{msg}->set_binary('FALSE');
print $test->data();
... I get the following result.
<?xml version="1.0" encoding="UTF-8" ?>
<?meta name="GENERATOR" content="XML::Smart/1.78 Perl/5.024001 [MSWin3
+2]" ?>
<log>
<logentry revision="12345">
<author>someAuthor</author>
<date>2017-10-11T09:32:15.704935Z</date>
<msg dt:dt="binary.base64">VGhpcyBpcyBteSBTVk4gbWVzc2FnZSB3aXRoIGN
+oYXJhY3RlcnMgbGlrZSDkIG9yICYu</msg>
</logentry>
</log>
If i call the subroutine data(decode => 1) the msg element contains the decoded message:
<msg>This is my SVN message with characters like ä or &.</msg>
But this output is invalid because "&" is not replaced by an escape sequence. I need an XML file with no Base64 encoding and escaped special XML characters like "&". All in one, a valid XML document without Base64 encoding. The XML parser which parses the output of the script can't handle Base64 encoding. I wonder if can solve the problem by using the subroutine set_binary('FALSE').
PS: I´m using Strawberry Perl v5.24.1 on Windows Server 2012 R2 Datacenter.
|