Parsing HTML with HTML::Tree
I am trying to parsing the following HTML content:
-- first part
<td class="storyTitle"> @0.1.7.4.0.0.5.0.0.11.1
-- second part
<td class="storyTitle"> @0.1.7.4.0.0.5.0.0.17.1
I am using HTML:Tree to parse the HTML and what I would like to do is
that whenever there isn't any <a href=.....> segment as in the second
part of the HTML, I will print something else, such as "Error
occurred". Notice that both first and second parts of the HTML have
common text of "<td class="storyTitle">", which I use for search
My problem is that I don't know what the following code will return
whenever <a href=...> is not found. I tried to test against "" or
undef, but doesn't seem to work.
The following is some of my code and it doesn't work as I wish.
if ($td->attr('class') eq 'storyTitle')
if (my $sym = $td->find('a'))
if ($sym->as_text() ne '')
print $sym->as_text() . "\n";
print "Error Occurred" . "\n";
Re: Parsing HTML with HTML::Tree
Thanks for your advice. You hit the nail on the head and it works
|All times are GMT. The time now is 04:06 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.