Subject: | Parsing SVGZ |
I accidentally tried to parse a compressed SVG file with SVG::Parser and
it failed with the error message:
not well-formed (invalid token) at line 1, column 0, byte 0 at
/usr/lib/perl5/XML/Parser.pm line 187
Maybe this error message could be more explicit. Even better, maybe
SVG::Parser could support parsing compressed SVG files!
Subject: | test.pl |
use strict;
use warnings;
use SVG::Parser;
use SVG::TT::Graph::Pie;
my $compress_svg = 1;
my @fields = qw(field_1 field_2 field_3);
my @data = qw(23 56 32);
print "Compress SVG file = $compress_svg\n";
print "Creating an SVG file...\n";
my $graph = SVG::TT::Graph::Pie->new({
# Required for some graph types
'fields' => \@fields,
'compress' => $compress_svg,
});
$graph->add_data({
'data' => \@data,
'title' => 'Sales 2002',
});
my $svg = $graph->burn();
print "Done...\n";
print "Parsing an SVG file...\n";
my $parser = SVG::Parser->new();
my $svg_obj = $parser->parse($svg);
print "Done...\n\n";