Subject: | Whitespace stripping problem |
It seems that xml_strip_whitespace does not strip all whitespace from an
xml file. A sample script showing the problem is below. I would expect
that both whitespace sections would disappear after calling
xml_strip_whitespace, but only the first one disappears.
I assume that using unbindNode while iterating using
XML::LibXML::Iterator could be dangerous, i.e. if the active node is
unbound, then the whole iterating process seems to stop. A simple fix is
to remove the $data eq "" special case in xml_strip_whitespace_text_node.
Regards,
Slaven
#!/usr/bin/perl
use strict;
use XML::LibXML;
use XML::Normalize::LibXML qw(xml_strip_whitespace);
my $test = <<EOF;
<foo> <bar/> </foo>
EOF
my $p = XML::LibXML->new;
my $dom = $p->parse_string($test);
xml_strip_whitespace($dom->documentElement);
print $dom->serialize;
__END__