SVG::P...:Expat(3pm)
π SVG::Parser::Expat β the manual, but make it cute β¨
okay bestie, gather round, because this is the Expat era and we're all just living in it. This page is SVG::Parser::Expat(3pm) from the User Contributed Perl Documentation β yes, that's the whole vibe. Let's get into it π«Ά
β¨ NAME β¨
SVG::Parser::Expat β it's the XML Expat Parser for SVG documents. iconic behaviour, honestly. π
π SYNOPSIS π
here's the whole thing, copy-paste ready, no cap:
#!/usr/bin/perl -w
use strict;
use SVG::Parser::Expat;
die "Usage: $0 <file>\n" unless @ARGV;
my $xml;
{
local $/=undef;
$xml=<>;
}
my $parser=new SVG::Parser::Expat;
my $svg=$parser->parse($xml);
print $svg->xmlify;
literally just read a file, parse it, print it back out. main character energy fr fr π
πΈ DESCRIPTION πΈ
so SVG::Parser::Expat is the Expat-specific parser module that SVG::Parser reaches for whenever an underlying XML::Parser-based parser gets selected. it's giving "the specialist". π§
and bestie, you can also use it directly β just like the synopsis up there shows you. no middleman needed.
- want maximum flexibility about which underlying parser gets chosen? use
SVG::Parser. that's the flexible one. π - want to supply Expat-specific parser options, or you already know
XML::Parseris present and/or you just prefer it? useSVG::Parser::Expat. that's this one. periodt.
π EXPORTS π
None. nope, nada, zero. π
BUT β plot twist β you can specify an alternative parent class (something other than XML::Parser) by passing the package name to SVG::Parser::Expat in the import list. like so:
use SVG::Parser::Expat qw(My::XML::Parser::Subclass);
where My::XML::Parser::Subclass is a subclass that looks a little something like:
package My::XML::Parser::Subclass;
use strict;
use vars qw(@ISA);
use XML::Parser;
@ISA=qw(XML::Parser);
...custom methods...
1;
and when it's loaded via SVG::Parser, you can specify that parent class by putting it after the = in a parser specification, like this:
use SVG::Parser qw(Expat=My::XML::Parser::Subclass);
See SVG::Parser for more details. iykyk π
π¦ EXAMPLES π¦
go look at "svgexpatparse" in the examples directory of the distribution. that's where the goods are. π
π AUTHOR π
Peter Wainwright, peter.wainwright@cybrid.net β shoutout to the legend who wrote this. π«Ά
π SEE ALSO π
go read these next, bestie, they're all connected:
SVGSVG::ParserSVG::Parser::SAXXML::Parser
lowkey a whole ecosystem. go forth and parse. π β¨
okay that's the whole page!! and just so you have the receipts β this is from perl v5.42.0, dated 2025-07-25. mwah, stay parsing, bestie πππ¦
π¦ where this page comes from
- fedora 43: perl-SVG-Parser 1.03-49.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms