SVG::P...:Expat(3pm)

πŸ“¦
version 1.03 Β· 2 versions
, in fedora 43

πŸ’– 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::Parser is present and/or you just prefer it? use SVG::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:

  • SVG
  • SVG::Parser
  • SVG::Parser::SAX
  • XML::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