Re: Getting XML::Twig to ignore certain elements?
by Michel Rodriguez other posts by this author
Jul 17 2001 8:03AM messages near this date
view in the new Beta List Site
Getting XML::Twig to ignore certain elements?
|
RE: Do characters <> cause problem with XML::Records?
On Tue, 10 Jul 2001, Danny Yoo wrote:
> Is there a way to get XML::Twig to not read certain elements? I'm working
> with some biological XMLs, and each data file has a really huge element
> approximately 50 MB long. Let's call its tag "FOOBAR". I'm trying to get
> XML::Twig to ignore FOOBAR, because it takes at least a few hours for
> XML::Twig to run through and construct it.
>
> Since this element is always at the end, I'm using the hacky solution of
> calling twig->finish() right before I hit FOOBAR; however, this feels
> unsatisfactory. I'd like a more robust solution where I can say something
> like:
>
> ###
> my $twig = XML::Twig->new(TwigHandlers => $handlers,
> IgnoreTags => 'FOOBAR');
> ###
>
> and have XML::Twig just skip over certain elements, avoiding the cost of
> constructing a PCDATA node. I haven't found such an 'IgnoreTags' option
> yet, so I'm wondering if anyone here could give any suggestions.
Hi,
That's what I get for going on vacation for 2 weeks, people keep working
in the meantime ;--)
I had been thinking about such an option but postponed implementing it as
long as nobody actually required it, as there will be a (hopefully small)
performance hit for all other users.
I can think of 2 useful ways to implement that feature:
IgnoreTags => ['FOOBAR'];
and a method that could be called from a start_tag_handler:
sub foobar # declared as a start_tag_handler
{ my( $t, $foobar)= @_;
if( $foobar-> att( 'baz') eq 'whatever value')
{ $foobar-> skip; }
}
I will have a look at it and get back to you about it later this week
hopefully.
Michel Rodriguez
Perl & XML
http://www.xmltwig.com
Toulouse Perl Mongers: http://toulouse.pm.org
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml
Thread:
Danny Yoo
Michel Rodriguez
|