Pie is good
-->
produces an HTML::Element object with these attributes:
"_tag",
"~comment",
"text",
" I like Pie.\n Pie is good\n "
=item Declaration pseudo-elements
Declarations (rarely encountered) are represented as HTML::Element
objects with a tag name of "~declaration", and content in the "text"
attribute. For example, this:
<!DOCTYPE foo>
produces an element whose attributes include:
"_tag", "~declaration", "text", "DOCTYPE foo"
=item Processing instruction pseudo-elements
PIs (rarely encountered) are represented as HTML::Element objects with
a tag name of "~pi", and content in the "text" attribute. For
example, this:
<?stuff foo?>
produces an element whose attributes include:
"_tag", "~pi", "text", "stuff foo?"
(assuming a recent version of HTML::Parser)
=item ~literal pseudo-elements
These objects are not currently produced by HTML::TreeBuilder, but can
be used to represent a "super-literal" -- i.e., a literal you want to
be immune from escaping. (Yes, I just made that term up.)
That is, this is useful if you want to insert code into a tree that
you plan to dump out with C<as_HTML>, where you want, for some reason,
to suppress C<as_HTML>'s normal behavior of amp-quoting text segments.
For example, this:
my $literal = HTML::Element->new('~literal',
'text' => 'x < 4 & y > 7'
);
my $span = HTML::Element->new('span');
$span->push_content($literal);
print $span->as_HTML;
prints this:
<span>x < 4 & y > 7</span>
Whereas this:
my $span = HTML::Element->new('span');
$span->push_content('x < 4 & y > 7');
# normal text segment
print $span->as_HTML;
prints this:
<span>x < 4 & y > 7</span>
Unless you're inserting lots of pre-cooked code into existing trees,
and dumping them out again, it's not likely that you'll find
C<~literal> pseudo-elements useful.
=back
=cut
sub tag {
my $self = shift;
if (@_) { # set
$self->{'_tag'} = $self->_fold_case($_[0]);
}
else { # get
$self->{'_tag'};
}
}
=head2 $h->parent() or $h->parent($new_parent)
Returns (optionally sets) the parent (aka "container") for this element.
The parent should either be undef, or should be another element.
You B<should not> use this to directly set the parent of an element.
Instead use any of the other methods under "Structure-Modifying
Methods", below.
Note that not($h->parent) is a simple test for whether $h is the
root of its subtree.
=4= |