XML::Filter::RemoveEmpty - Filter out tags with no character data
Version 0.02
Removes tags which contain neither character data nor descendants containing character data. Considers whitespace meaningless by default and trims it, but can preserve it; defaults to removing comments, but this can also be changed.
use XML::Filter::RemoveEmpty; use XML::SAX::Machines qw( :all ); my $filter = XML::Filter::RemoveEmpty->new( Comments => 'strip' # (default) # or Comments => 'preserve', # (NOT WORKING) TrimWhitespace => 'only' # (only removes ws-only data) # or # TrimWhitespace => 'always' # (default - always trims leading and trailing whitespace) ); my $machine = Pipeline( $filter => \*STDOUT ); $machine->parse_file(\*STDIN);
Overrides new(), start_element(), end_element(), characters(), and comment() from XML::SAX::Base.
Takes a list of key-value pairs for configuration (see SYNOPSIS).
See "start_element" in XML::SAX::Base
See "end_element" in XML::SAX::Base
See "characters" in XML::SAX::Base
See "comment" in XML::SAX::Base
Called when character data encountered; generates SAX events for pending tags
Does string manipulation depending on trim settings
May not preserve the content ordering of mixed-content tags (a tag with both character data and other tags within it). Specifically, all character data in a particular tag will be printed together before any inner tags are printed.
Comments are currently always stripped because of a weakness in implmentation.
Please report any bugs or feature requests to bug-xml-filter-removeempty at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-Filter-RemoveEmpty. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-xml-filter-removeempty at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc XML::Filter::RemoveEmpty
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/XML-Filter-RemoveEmpty
CPAN Ratings
http://cpanratings.perl.org/d/XML-Filter-RemoveEmpty
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-Filter-RemoveEmpty
Search CPAN
http://search.cpan.org/dist/XML-Filter-RemoveEmpty
XML::Filter::Sort, whose SYNOPSIS I stole.
Darren Kulp, <darren at kulp.ch>
<darren at kulp.ch>
Copyright 2006 Darren Kulp, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::Filter::RemoveEmpty, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Filter::RemoveEmpty
CPAN shell
perl -MCPAN -e shell install XML::Filter::RemoveEmpty
For more information on module installation, please visit the detailed CPAN module installation guide.