Why not adopt me?
NAME
XML::Filter::RemoveEmpty - Filter out tags with no character data
VERSION
Version 0.02
SYNOPSIS
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);
METHODS
Overrides new(), start_element(), end_element(), characters(), and comment() from XML::SAX::Base.
- new
-
Takes a list of key-value pairs for configuration (see SYNOPSIS).
- start_element
- end_element
- characters
- comment
- _print_stack
-
Called when character data encountered; generates SAX events for pending tags
- _handle_text
-
Does string manipulation depending on trim settings
BUGS
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.
SUPPORT
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
CPAN Ratings
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-Filter-RemoveEmpty
Search CPAN
ACKNOWLEDGEMENTS
XML::Filter::Sort, whose SYNOPSIS I stole.
AUTHOR
Darren Kulp, <darren at kulp.ch>
COPYRIGHT & LICENSE
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.