Perlbeginner1 has asked for the wisdom of the Perl Monks concerning the following question:
is this all right ? See one of the example sites: http://www.kultusportal-bw.de/servlet/PB/menu/1188427/index.html?COMPLETEHREF=http://www.kultus-bw.de/did_abfrage/detail.php?id=04313488use strict; use HTML::TreeBuilder::XPath; my $tree = HTML::TreeBuilder::XPath->new; #use real file name here open(my $fh, "<", "file.html") or die $!; $tree->parse_file($fh); my ($name) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($type) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($adress) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($adress_two) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($telephone) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($fax) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($internet) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($officer) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($employees) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($offices) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($worker) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($country) = $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); my ($the_council)= $tree->findnodes(qq{/html/body/table/tr[1]/td[2]}); print $name->as_text; print $type->as_text; print $adress->as_text; print $adress_two->as_text; print $telephone->as_text; print $fax->as_text; print $internet->as_text; print $officer->as_text; print $employees->as_text; print $offices->as_text; print $worker->as_text; print $country->as_text; print $the_council->as_text;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Xpather running against a simple HTML-document - testing and evaluation
by ww (Archbishop) on Oct 16, 2010 at 14:31 UTC | |
|
Re: Xpather running against a simple HTML-document - testing and evaluation
by morgon (Priest) on Oct 16, 2010 at 16:35 UTC | |
by Perlbeginner1 (Scribe) on Oct 16, 2010 at 19:32 UTC | |
|
Re: Xpather running against a simple HTML-document - testing and evaluation
by Anonymous Monk on Oct 16, 2010 at 14:00 UTC |