http://www.perlmonks.org?node_id=105304


in reply to XML::Parser breaks on

I think you'll have to glue it all together. Here is a snippet that might help a bit.

sub xml_char { my ($xp, $txt) = @_; my $el = $xp->current_element(); $val{$el} .= $txt if $txt =~ /\S/; }

Notice that %val is sort of a buffer area that will need to be cleaned up when you hit the end tag.

-Blake

Replies are listed 'Best First'.
Re: Re: XML::Parser breaks on
by clintp (Curate) on Aug 16, 2001 at 17:31 UTC
    I've used something like this before, and like the general technique, but I question:
    $val{$el}.=$txt if $txt =~ /\S/;
    Since the parser is actually allowed to break anywhere you could lose intra-word spaces or newlines (if they're signicficant).
      You're probably right and its a piece of code I haven't looked at in a long time. I do remember there being a reson for it, but can't remember it right now. Anyone looking at using this, should probably get rid of the if conditional.

      -Blake