を使用してXML::Twig
、ノードのHTML全体を取得する方法はありますか?ノードのテキストは必要ありませんが、タグとすべてを含むHTML全体が必要です。
入力XML
<content> <p>blah blah <b> bla bla </b> </p>
<p> line 2 <i> test </i? </p>
</content>
コード
my $twig = new XML::Twig(
TwigRoots => {'content' => 1},
TwigHandlers => $twig_handlers
);
my $twig_handlers = {'count/p' => \&count_ps};
sub count_ps {
my ($twig, $test) = @_;
$Data .= $test->text();
}
$data
HTML全体を表示する必要があります。