Parser:...::Stream(3)

πŸ’– NAME πŸ’–

okay so this page is Parser:...::Stream(3) from the User Contributed Perl Documentation, and the module is XML::Parser::Style::Stream β€” Stream style for XML::Parser. slay, that's the whole name vibe. ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

bestie, here's the starter pack, exactly as it goes:

  use XML::Parser;
  my $p = XML::Parser->new(Style => 'Stream', Pkg => 'MySubs');
  $p->parsefile('foo.xml');

  {
    package MySubs;

    sub StartTag {
      my ($e, $name) = @_;
      # do something with start tags
    }

    sub EndTag {
      my ($e, $name) = @_;
      # do something with end tags
    }

    sub Characters {
      my ($e, $data) = @_;
      # do something with text nodes
    }
  }

✨ DESCRIPTION ✨

This style uses the Pkg option to find subs in a given package to call for each event. periodt. And no cap: if none of the subs that this style looks for is there, then the effect of parsing with this style is to print a canonical copy of the document without comments or declarations. 🀯

Vibe check: all the subs receive the Expat instance for the document they're parsing as their 1st parameter. main character energy, honestly. πŸ’…

It looks for the following routines:

  • StartDocument β€” called at the start of the parse. 🎬
  • StartTag β€” called for every start tag, with a second parameter of the element type. The $_ variable will contain a copy of the tag, and the %_ variable will contain attribute values supplied for that element. πŸ‘‘
  • EndTag β€” called for every end tag, with a second parameter of the element type. The $_ variable will contain a copy of the end tag. πŸŽ€
  • Text β€” called just before start or end tags, with accumulated non-markup text in the $_ variable. πŸ“
  • PI β€” called for processing instructions. The $_ variable will contain a copy of the PI, and the target and data are sent as 2nd and 3rd parameters respectively. 🧚
  • EndDocument β€” called at conclusion of the parse. 🌈

mwah πŸ’‹ that's the whole page! This one is from perl v5.42.0, dated 2026-03-20, and the page name is Parser:...::Stream(3). πŸŽ€βœ¨