-1

I am trying to use xpath in WebHarvest and I am able to receive a large list of data, however I only need the first 5 strings returned.

<var-def name="googleProducts">
    <html-to-xml>
        <http url="http://google.com/shopping?q=fila skele-toes&amp;hl=en"/>
    </html-to-xml>
</var-def>
<var-def name="googlePrices">
    <xpath expression="//div[@id='center_col']//div[@class='psliprice']/div[1]/text()">
        <var name="googleProducts"></var>
    </xpath>
</var-def>

I have tried using *[position()<6] but i get the error the value of attribute "expression" associated with an element type "null" must not contain the '<' character

1 Answers1

0

This expression is valid, and should accomplish your goal:

<xpath expression="//div[@id='center_col']//div[@class='psliprice' and position()<=5]/div[1]/text() ">

Fiddle Example

Nix
  • 57,072
  • 29
  • 149
  • 198