Created
March 22, 2010 22:07
-
-
Save wki/340590 to your computer and use it in GitHub Desktop.
my first 2-html html::zoom thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use HTML::Zoom; | |
my $html = <<HTML; | |
<html> | |
<head> | |
<title>Hello people</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
</body> | |
</html> | |
HTML | |
my $body = <<HTML; | |
<h1 id="greeting">Placeholder</h1> | |
<div id="list"> | |
<span> | |
<p>Name: <span class="name">Bob</span></p> | |
<p>Age: <span class="age">23</span></p> | |
</span> | |
<hr class="between" /> | |
</div> | |
HTML | |
my $html_zoom = HTML::Zoom->from_html($html) | |
->select('title') | |
->replace_content('Hello everybody'); | |
my $body_zoom = HTML::Zoom->from_html($body) | |
->select('#greeting') | |
->replace_content('Hello everybody') | |
; | |
my $sum_zoom = $html_zoom->select('#content') | |
->append_content($body_zoom->{initial_events}) | |
; | |
print $sum_zoom->to_html; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment