Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created September 22, 2010 19:29
Show Gist options
  • Save jjn1056/592333 to your computer and use it in GitHub Desktop.
Save jjn1056/592333 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use HTML::Zoom;
my $root = HTML::Zoom
->from_html(<<MAIN);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>My Page Title</title>
</head>
<body>
<div id="sidebar">Test Sidebar</div>
<div id="content">
<span id="p1">test label</span>
</div>
</body>
</html>
MAIN
my $label_html = HTML::Zoom
->from_html(<<LABEL);
<div id="stuff">Stuff</div>
LABEL
use Data::Dump 'dump';
warn $root
->select('#p1')
->replace_content($label_html)
->select('#stuff')
->replace_content('Double Stuffed')
->to_html;
my $selected = HTML::Zoom->new;
$root
->select('#p1')
->collect_content({into=>sub {}})
->run;
warn dump $selected;
warn $root->select('#p1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment