xmltv

 view release on metacpan or  search on metacpan

lib/XMLTV.pm.in  view on Meta::CPAN

# Parameter: whether newlines are allowed (defaults to false)
#
sub get_text( $;$ ) {
    my $node = shift;
    my $allow_nl = shift; $allow_nl = 0 if not defined $allow_nl;
    my @children = get_subelements($node);
    if (@children == 0) {
	return '';
    }
    elsif (@children == 1) {
	my $v = $children[0]->pcdata();
	t 'got pcdata: ' . d $v;
	if (not defined $v) {
	    my $name = get_name($node);
	    warn "node $name expected to contain text has other stuff\n";
	}
	else {
	    # Just hope that the encoding we got uses \n...
	    if (not $allow_nl and $v =~ tr/\n//d) {
		my $name = get_name($node);
		warn "removing newlines from content of node $name\n";
	    }



( run in 0.234 second using v1.01-cache-2.11-cpan-454fe037f31 )