NAME
HTML::Zoom::FilterBuilder - Add Filters to a Stream
SYNOPSIS
Create an HTML::Zoom instance:
use HTML::Zoom;
my $root = HTML::Zoom
->from_html(<<MAIN);
<html>
<head>
<title>Default Title</title>
</head>
<body bad_attr='junk'>
Default Content
</body>
</html>
MAIN
Create a new attribute on the body
tag:
$root = $root
->select('body')
->set_attribute(class=>'main');
Add a extra value to an existing attribute:
$root = $root
->select('body')
->add_to_attribute(class=>'one-column');
Set the content of the title
tag:
$root = $root
->select('title')
->replace_content('Hello World');
Set content from another HTML::Zoom instance:
my $body = HTML::Zoom
->from_html(<<BODY);
<div id="stuff">
<p>Well Now</p>
<p id="p2">Is the Time</p>
</div>
BODY
$root = $root
->select('body')
->replace_content($body);
Set an attribute on multiple matches:
$root = $root
->select('p')
->set_attribute(class=>'para');
Remove an attribute:
$root = $root
->select('body')
->remove_attribute('bad_attr');
will produce:
<html>
<head>
<title>Hello World</title>
</head>
<body class="main one-column"><div id="stuff">
<p class="para">Well Now</p>
<p id="p2" class="para">Is the Time</p>
</div>
</body>
</html>
DESCRIPTION
Given a HTML::Zoom stream, provide methods to apply filters which alter the content of that stream.
METHODS
This class defines the following public API
set_attribute ( $attr=>value | {name=>$attr,value=>$value} )
Sets an attribute of a given name to a given value for all matching selections.
$html_zoom
->select('p')
->set_attribute(class=>'paragraph')
->select('div')
->set_attribute(name=>'class', value=>'divider');
Overrides existing values, if such exist. When multiple "set_attribute" calls are made against the same or overlapping selection sets, the final call wins.
add_to_attribute ( $attr=>value | {name=>$attr,value=>$value} )
Adds a value to an existing attribute, or creates one if the attribute does not yet exist.
$html_zoom
->select('p')
->set_attribute(class=>'paragraph')
->then
->add_to_attribute(name=>'class', value=>'divider');
Attributes with more than one value will have a dividing space.
remove_attribute ( $attr | {name=>$attr} )
Removes an attribute and all its values.
$html_zoom
->select('p')
->set_attribute(class=>'paragraph')
->then
->remove_attribute('class');
Removes attributes from the original stream or events already added.
collect
TBD
collect_content
TBD
add_before
TBD
add_after
TBD
prepend_content
TBD
append_content
TBD
replace
TBD
replace_content
Given a "select" in HTML::Zoom result, replace the content with a string, array or another HTML::Zoom object.
repeat
TBD
repeat_content
TBD
ALSO SEE
AUTHORS
See HTML::Zoom for authors.
LICENSE
See HTML::Zoom for the license.