{"id":298,"date":"2026-10-21T19:47:18","date_gmt":"2026-10-21T11:47:18","guid":{"rendered":"https:\/\/glossary.clawoxy.com\/?p=298"},"modified":"2026-10-23T20:33:42","modified_gmt":"2026-10-23T12:33:42","slug":"xpath-selector","status":"publish","type":"post","link":"https:\/\/www.clawoxy.com\/glossary\/xpath-selector\/","title":{"rendered":"XPath Selector"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">An XPath selector is an XPath expression used to choose nodes from an XML or HTML document. A crawler can use it to extract text, attributes, or groups of elements such as product cards or article links.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Make the selector match the page&#8217;s structure<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use stable attributes and relationships instead of counting nested <code>div<\/code> elements. For example, select a card by a known class and then find its title within that card, rather than querying every title on the page and hoping order stays fixed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether the selector returns zero, one, or many results, and handle each case deliberately. A zero result may mean the page changed, the wrong response was parsed, or the content is loaded later with JavaScript. Inspect the raw response before rewriting the selector.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Different libraries expose XPath results in different forms. Read the framework&#8217;s documentation and test a saved response sample before running at scale.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.w3.org\/TR\/xpath-31\/\">W3C: XPath 3.1<\/a><\/li>\n<li><a href=\"https:\/\/docs.scrapy.org\/en\/latest\/topics\/selectors.html\">Scrapy: Selectors<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>An XPath selector is an XPath expression used to choose nodes from an XML or HTML document. A crawler can use it to extract text, attributes, or groups of elements such as product cards or article links. Make the selector match the page&#8217;s structure Use stable attributes and relationships instead of counting nested div elements. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-298","post","type-post","status-publish","format-standard","hentry","category-glossary"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>XPath Selector - glossary<\/title>\n<meta name=\"description\" content=\"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/glossary.clawoxy.com\/xpath-selector\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"XPath Selector - glossary\" \/>\n<meta property=\"og:description\" content=\"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/glossary.clawoxy.com\/xpath-selector\/\" \/>\n<meta property=\"og:site_name\" content=\"glossary\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-21T11:47:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-23T12:33:42+00:00\" \/>\n<meta name=\"author\" content=\"Victoria\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Victoria\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/\"},\"author\":{\"name\":\"Victoria\",\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#\\\/schema\\\/person\\\/f2cd3fd0bdf481ab8a9d402da0fdeb5c\"},\"headline\":\"XPath Selector\",\"datePublished\":\"2026-10-21T11:47:18+00:00\",\"dateModified\":\"2026-10-23T12:33:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/\"},\"wordCount\":160,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#organization\"},\"articleSection\":[\"Glossary\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/\",\"url\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/\",\"name\":\"XPath Selector - glossary\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#website\"},\"datePublished\":\"2026-10-21T11:47:18+00:00\",\"dateModified\":\"2026-10-23T12:33:42+00:00\",\"description\":\"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/glossary.clawoxy.com\\\/xpath-selector\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/www.clawoxy.com\\\/glossary\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"XPath Selector\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#website\",\"url\":\"https:\\\/\\\/47.84.23.125\\\/\",\"name\":\"clawoxy glossary\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/47.84.23.125\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#organization\",\"name\":\"clawoxy\",\"url\":\"https:\\\/\\\/47.84.23.125\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/47.84.23.125:443\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/logo_light_600.png\",\"contentUrl\":\"https:\\\/\\\/47.84.23.125:443\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/logo_light_600.png\",\"width\":600,\"height\":145,\"caption\":\"clawoxy\"},\"image\":{\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/47.84.23.125\\\/#\\\/schema\\\/person\\\/f2cd3fd0bdf481ab8a9d402da0fdeb5c\",\"name\":\"Victoria\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g\",\"caption\":\"Victoria\"},\"url\":\"https:\\\/\\\/www.clawoxy.com\\\/glossary\\\/author\\\/victoria\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"XPath Selector - glossary","description":"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/glossary.clawoxy.com\/xpath-selector\/","og_locale":"en_US","og_type":"article","og_title":"XPath Selector - glossary","og_description":"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.","og_url":"https:\/\/glossary.clawoxy.com\/xpath-selector\/","og_site_name":"glossary","article_published_time":"2026-10-21T11:47:18+00:00","article_modified_time":"2026-10-23T12:33:42+00:00","author":"Victoria","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Victoria","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/#article","isPartOf":{"@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/"},"author":{"name":"Victoria","@id":"https:\/\/47.84.23.125\/#\/schema\/person\/f2cd3fd0bdf481ab8a9d402da0fdeb5c"},"headline":"XPath Selector","datePublished":"2026-10-21T11:47:18+00:00","dateModified":"2026-10-23T12:33:42+00:00","mainEntityOfPage":{"@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/"},"wordCount":160,"commentCount":0,"publisher":{"@id":"https:\/\/47.84.23.125\/#organization"},"articleSection":["Glossary"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/glossary.clawoxy.com\/xpath-selector\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/","url":"https:\/\/glossary.clawoxy.com\/xpath-selector\/","name":"XPath Selector - glossary","isPartOf":{"@id":"https:\/\/47.84.23.125\/#website"},"datePublished":"2026-10-21T11:47:18+00:00","dateModified":"2026-10-23T12:33:42+00:00","description":"An XPath selector is an XPath expression used to choose nodes from an XML or HTML document.","breadcrumb":{"@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/glossary.clawoxy.com\/xpath-selector\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/glossary.clawoxy.com\/xpath-selector\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.clawoxy.com\/glossary\/"},{"@type":"ListItem","position":2,"name":"XPath Selector"}]},{"@type":"WebSite","@id":"https:\/\/47.84.23.125\/#website","url":"https:\/\/47.84.23.125\/","name":"clawoxy glossary","description":"","publisher":{"@id":"https:\/\/47.84.23.125\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/47.84.23.125\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/47.84.23.125\/#organization","name":"clawoxy","url":"https:\/\/47.84.23.125\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/47.84.23.125\/#\/schema\/logo\/image\/","url":"https:\/\/47.84.23.125:443\/wp-content\/uploads\/2026\/10\/logo_light_600.png","contentUrl":"https:\/\/47.84.23.125:443\/wp-content\/uploads\/2026\/10\/logo_light_600.png","width":600,"height":145,"caption":"clawoxy"},"image":{"@id":"https:\/\/47.84.23.125\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/47.84.23.125\/#\/schema\/person\/f2cd3fd0bdf481ab8a9d402da0fdeb5c","name":"Victoria","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/58bdb169212e5e6416fff3eb32931f742da3e068cf0b5e5b8b484c54bf773c77?s=96&d=mm&r=g","caption":"Victoria"},"url":"https:\/\/www.clawoxy.com\/glossary\/author\/victoria\/"}]}},"_links":{"self":[{"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/posts\/298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/comments?post=298"}],"version-history":[{"count":1,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/posts\/298\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/posts\/298\/revisions\/299"}],"wp:attachment":[{"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/categories?post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clawoxy.com\/glossary\/wp-json\/wp\/v2\/tags?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}