->from_html(<<BODY);
<div id="stuff">
<p>Well Now</p>
- <p>Is the Time</p>
+ <p id="p2">Is the Time</p>
</div>
BODY
my $output = $root
-->select('title')
-->replace_content('Hello World')
-->select('body')
-->replace_content($body)
-->select('p')
-->set_attribute(class=>'para')
-->to_html;
+ ->select('title')
+ ->replace_content('Hello World')
+ ->select('body')
+ ->replace_content($body)
+ ->then
+ ->set_attribute(class=>'main')
+ ->select('p')
+ ->set_attribute(class=>'para')
+ ->select('#p2')
+ ->set_attribute(class=>'para2')
+ ->to_html;
my $expect = <<HTML;
<head>
<title>Hello World</title>
</head>
- <body><div id="stuff">
+ <body class="main"><div id="stuff">
<p class="para">Well Now</p>
- <p class="para">Is the Time</p>
+ <p id="p2" class="para2">Is the Time</p>
</div>
</body>
</html>