Changeset 2394

Show
Ignore:
Timestamp:
11/21/07 10:21:01
Author:
miyagawa
Message:

accept id() function as XPath not CSS selector

Files:

Legend:

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

    r2379 r2394  
    122122        my($exp, @attr) = @_; 
    123123 
    124         my $xpath = $exp =~ m!^/! ? $exp : HTML::Selector::XPath::selector_to_xpath($exp); 
     124        my $xpath = $exp =~ m!^(?:/|id\()! ? $exp : HTML::Selector::XPath::selector_to_xpath($exp); 
    125125        my @nodes = eval { 
    126126            local $SIG{__WARN__} = sub { }; 
     
    175175    } elsif (lc($val) eq 'raw' || lc($val) eq 'html') { 
    176176        if ($node->isTextNode) { 
    177             # xxx is this a bug? as_XML doesn't return encoded output 
    178             return HTML::Entities::encode($node->as_XML, q("'<>&)); 
     177            if ($HTML::TreeBuilder::XPath::VERSION < 0.09) { 
     178                return HTML::Entities::encode($node->as_XML, q("'<>&)); 
     179            } else { 
     180                return $node->as_XML; 
     181            } 
    179182        } 
    180183        my $html = $node->as_XML;