Reputation:
HTML Structure is,
<div class="profile-content"><section class="content-section"><h3 class="subheader">Welcome to the party</h3>
I want to print
Welcome to the party
Code is as below,
my $profile= $tree->findvalue('//div[@class="profile-content"]/section[@class="content-section"]/h3[@class="subheader"]');
But it is not printing anything.
Please help me.
Regards
Upvotes: 1
Views: 152
Reputation: 16161
<section>
is an HTML5 tag, which is not recognized by HTML::TreeBuilder. By default it is not present in the internal representation of the HTML.
Setting the ignore_unknown
option to 0 (false) should give you what you want.
See the difference:
> perl -MHTML::TreeBuilder -E'my $t=HTML::TreeBuilder->new; $t->parse( q{<div class="profile-content"><section class="content-section"><h3 class="subheader">Welcome to the party</h3>}); say $t->as_HTML'
<html><head></head><body><div class="profile-content"><h3 class="subheader">Welcome to the party</h3></div></body></html>
> perl -MHTML::TreeBuilder -E'my $t=HTML::TreeBuilder->new; $t->ignore_unknown( 0); $t->parse( q{<div class="profile-content"><section class="content-section"><h3 class="subheader">Welcome to the party</h3>}); print $t->as_HTML'
<html><head></head><body><div class="profile-content"><section class="content-section"><h3 class="subheader">Welcome to the party</h3></section></div></body></html>
Upvotes: 2