File: issue-12.t

package info (click to toggle)
libhtml-treebuilder-libxml-perl 0.28-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 264 kB
  • sloc: perl: 533; makefile: 2; sh: 1
file content (20 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use strict;
use warnings;
use Test::More;
use HTML::TreeBuilder::LibXML;

# https://github.com/tokuhirom/HTML-TreeBuilder-LibXML/issues/12

my $html = <<EOF;
<html><a href="/">top</a></html>
EOF

my $tree = HTML::TreeBuilder::LibXML->new;
$tree->parse($html);
$tree->eof;
my ($element) = $tree->findnodes('//a');
my $new_element = ref($element)->new('div', foo => 'bar');
$element->replace_with($new_element);
is $tree->as_HTML, q{<html><body><div foo="bar"></div></body></html>};

done_testing;