     [Answers](https://scrapfly.io/blog)   /  [xpath](https://scrapfly.io/blog/tag/xpath)   /  [How to select elements of a specific position in XPath?](https://scrapfly.io/blog/answers/how-to-select-elements-of-specific-position-in-xpath)   # How to select elements of a specific position in XPath?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Apr 19, 2023 1 min read [\#xpath](https://scrapfly.io/blog/tag/xpath) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath "Share on LinkedIn") [  ](https://x.com/intent/tweet?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath&text=How%20to%20select%20elements%20of%20a%20specific%20position%20in%20XPath%3F "Share on X") [  ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath "Share on Facebook")    

 

 

Summarize this article with

 [  ](https://chat.openai.com/?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath) [  ](https://claude.ai/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath) [  ](https://x.com/i/grok?text=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath) [  ](https://www.perplexity.ai/search/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath) [  ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-select-elements-of-specific-position-in-xpath) 



To select elements of a specific position the `position()` function can be used with a predicate:

&lt;!-- select all product detail urls --&gt; &lt;html&gt; &lt;div&gt; &lt;h2&gt;Product 1&lt;/h2&gt; &lt;a href="/product/1/reviews"&gt;reviews&lt;/a&gt; &lt;a href="/product/1/details"&gt;details&lt;/a&gt; &lt;a href="/product/1/refunds"&gt;refunds&lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;h2&gt;Product 2&lt;/h2&gt; &lt;a href="/product/2/reviews"&gt;reviews&lt;/a&gt; &lt;a href="/product/2/details"&gt;details&lt;/a&gt; &lt;a href="/product/2/refunds"&gt;refunds&lt;/a&gt; &lt;/div&gt; &lt;/html&gt; Note that using `position()` when web scraping is not recommended as HTML element position is likely to change. Instead other methods like [selection by attribute value](https://scrapfly.io/blog/answers/how-to-select-elements-by-attribute-value-in-xpath) is a more reliable way if applicable.



 

   [  Add as a preferred source ](https://google.com/preferences/source?q=scrapfly.io)   Join the Newsletter  Get monthly web scraping insights 

 

  



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

 ## Related Articles

 [  

 python data-parsing 

### Parsing HTML with Xpath

Introduction to xpath in the context of web-scraping. How to extract data from HTML documents using xpath, best practice...

 

 ](https://scrapfly.io/blog/posts/parsing-html-with-xpath) [  

 data-parsing xpath 

### Ultimate XPath Cheatsheet for HTML Parsing in Web Scraping

Ultimate companion for HTML parsing using XPath selectors. This cheatsheet contains all syntax explanations with interac...

 

 ](https://scrapfly.io/blog/posts/xpath-cheatsheet) [  

 data-parsing css-selectors 

### How to find HTML elements by class?

To find HTML nodes by class name CSS selectors or XPath can be used. For that .class css selector can be used or XPath's...

 

 ](https://scrapfly.io/blog/posts/how-to-find-html-elements-by-class) 

  ## Related Questions

- [ Q How to select elements by ID in XPath? ](https://scrapfly.io/blog/answers/how-to-select-elements-by-id-in-xpath)
- [ Q How to find elements by XPath in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-puppeteer)
- [ Q How to select elements by text in XPath? ](https://scrapfly.io/blog/answers/how-to-select-elements-by-text-in-xpath)
- [ Q How to select elements by class in XPath? ](https://scrapfly.io/blog/answers/how-to-select-elements-by-class-in-xpath)
 
  



   



 Scale your web scraping effortlessly, **1,000 free credits** [Start Free](https://scrapfly.io/register)