Can Perl's HTML::Selector::XPath be used for the general purpose of finding XPaths?
Can Perl's HTML::Selector::XPath be used for the general purpose of finding XPaths?
use HTML::Selector::XPath;
my $selector = HTML::Selector开发者_如何学JAVA::XPath->new("li#main");
$selector->to_xpath; # //li[@id='main']
# functional interface
use HTML::Selector::XPath 'selector_to_xpath';
my $xpath = selector_to_xpath('div.foo');
HTML::Selector::XPath takes a CSS selector and converts it to an equivalent XPath expression. It doesn't let you search an HTML file for matching elements. Maybe you're looking for HTML::TreeBuilder::XPath or HTML::Query.
精彩评论