Zak
Zak

Reputation: 35

How can I cap my result to 1 with importXML

Using importXML I am searching for the class 'current' which contains 'current-price'. Using this code it returns the same result 3 times as the 'current' class exists 3 times on the website.

=importxml("https://www.currys.co.uk/gbuk/tv-and-home-entertainment/televisions/televisions/lg-55sm8200pla-55-smart-4k-ultra-hd-hdr-led-tv-with-google-assistant-10191769-pdt.html", "//div//strong[contains(@class, 'current')]")

enter image description here

Is there a simple way to cap my search to 1 result so that it doesn't overlap data on the row below?

Upvotes: 1

Views: 39

Answers (1)

player0
player0

Reputation: 1

sure, you can use INDEX like:

=INDEX(IMPORTXML("https://www.currys.co.uk/gbuk/tv-and-home-entertainment/televisions/televisions/lg-55sm8200pla-55-smart-4k-ultra-hd-hdr-led-tv-with-google-assistant-10191769-pdt.html", 
 "//div//strong[contains(@class, 'current')]"), 1, 1)

Upvotes: 1

Related Questions