#!/usr/bin/perl -w
use strict;
use HTML::Scrubber;
use feature 'say';
my @default = (
1 => {
'*' => 1,
itemprop => 0,
itemscope => 0,
itemtype => 0,
}
);
my $scrubber = HTML::Scrubber->new(
default => \@default,
process => 0,
);
my $html = join( '', <DATA> );
say $scrubber->scrub($html);
__DATA__
<div itemscope itemtype ="http://schema.org/Movie">
<h1 itemprop="name">Avatar</h1>
<span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span>
<span itemprop="genre">Science fiction</span>
<a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a>
</div>
Результат:
<div>
<h1>Avatar</h1>
<span>Director: <span>James Cameron</span> (born August 16, 1954)</span>
<span>Science fiction</span>
<a href="../movies/avatar-theatrical-trailer.html">Trailer</a>
</div>