Можно ли использовать Perl HTML :: Selector :: XPath для общего поиска XPath?
use HTML::Selector::XPath;
my $selector = HTML::Selector::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');