Changeset 2252

Show
Ignore:
Timestamp:
05/10/07 10:20:13
Author:
miyagawa
Message:

if expression starts with /, it's treated as direct XPath expression, not CSS selector.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Web-Scraper/trunk/lib/Web/Scraper.pm

    r2246 r2252  
    9999        my($exp, @attr) = @_; 
    100100 
    101         my $xpath = HTML::Selector::XPath::selector_to_xpath($exp); 
     101        my $xpath = $exp =~ m!^/! ? $exp : HTML::Selector::XPath::selector_to_xpath($exp); 
    102102        my @nodes = $tree->findnodes($xpath) or return; 
    103103        @nodes = ($nodes[0]) if $first; 
  • Web-Scraper/trunk/t/01_process.t

    r2239 r2252  
    44use Web::Scraper; 
    55plan tests => 1 * blocks; 
    6  
    76 
    87filters { 
     
    3837--- expected 
    3938baz 
     39 
     40=== 
     41--- html 
     42<span><a href="foo">baz</a></span> 
     43--- selector 
     44//span/a 
     45--- expected 
     46baz