Skip to content

Instantly share code, notes, and snippets.

@wki
Created March 22, 2010 22:07
Show Gist options
  • Save wki/340590 to your computer and use it in GitHub Desktop.
Save wki/340590 to your computer and use it in GitHub Desktop.
my first 2-html html::zoom thing
#!/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