{"id":384321,"date":"2023-06-21T06:29:05","date_gmt":"2023-06-21T06:29:05","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=384321"},"modified":"2026-01-22T14:06:37","modified_gmt":"2026-01-22T14:06:37","slug":"xpath-with-multiple-elements","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/","title":{"rendered":"How to create an XPath with multiple elements"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is XPath?<\/h3>\n\n\n\n<p><strong>XPath (XML Path Language)<\/strong> is a query language used to <strong>navigate, locate, and select elements or values from XML documents<\/strong>.<\/p>\n\n\n\n<p>In modern practice, XPath is also widely used to locate elements in <strong>HTML (DOM) structures<\/strong>, especially in <strong>automation testing and web scraping<\/strong>, where precise element identification is required.<\/p>\n\n\n\n<p>XPath was designed to describe <strong>paths to elements inside an XML document<\/strong>, similar to how file paths work in an operating system, making it easy to traverse structured data.<\/p>\n\n\n\n<p>In this guide, we will dive into <strong>creating XPath expressions with multiple conditions<\/strong>, so you can handle dynamic web pages confidently and efficiently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does understanding HTML structure help you write reliable XPath?<\/h3>\n\n\n\n<p>Before you start writing an XPath, it is crucial to <strong>understand the HTML structure of the webpage<\/strong> you are working with.<\/p>\n\n\n\n<p>Every webpage is made up of a hierarchy of HTML elements \u2014 tags like <code>&lt;div&gt;<\/code>, <code>&lt;input&gt;<\/code>, <code>&lt;button&gt;<\/code>, and <code>&lt;span&gt;<\/code> \u2014 that are often nested within one another. Understanding this hierarchy allows you to <strong>see how elements relate to each other<\/strong> and which ones are siblings, children, or parents.<\/p>\n\n\n\n<p>For example, consider this snippet:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;form id=\"loginForm\">\n  &lt;label for=\"userEmail\">Email&lt;\/label>\n  &lt;input type=\"email\" id=\"userEmail\" name=\"email\" placeholder=\"Enter your email\">\n  &lt;button type=\"submit\">Login&lt;\/button>\n&lt;\/form>\n<\/pre>\n\n\n\n<p>In the above HTML Structure,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>&lt;input><\/code> element is a <strong>child<\/strong> of the <code>&lt;form><\/code> element.<\/li>\n\n\n\n<li>The <code>&lt;label><\/code> element is a <strong>sibling<\/strong> of the input field.<\/li>\n\n\n\n<li>The <code>&lt;button><\/code> element is <strong>another sibling<\/strong> within the same form.<\/li>\n\n\n\n<li>When you understand this DOM hierarchy, you can write XPath expressions that locate elements <strong>relative to other elements<\/strong>, instead of relying on IDs.<\/li>\n<\/ul>\n\n\n\n<p>For instance, locating the email input based on its label instead of its ID:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/label[text()='Email:']\/following-sibling::input\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why XPath Is Highly Relevant in 2026<\/h3>\n\n\n\n<p>This approach ensures your XPath works even if <strong>dynamic IDs or classes change<\/strong>, making your automation more robust.<\/p>\n\n\n\n<p>in 2026, XPath continues to play a crucial role due to its <strong>accuracy, flexibility, and broad industry adoption<\/strong>, especially in test automation and enterprise applications where dynamic UI structures are common.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Essential for Test Automation Frameworks<\/h4>\n\n\n\n<p>XPath remains a primary locator strategy in popular automation tools such as <strong>Selenium, Playwright, Cypress (via plugins), and Appium<\/strong>. When unique IDs or stable CSS selectors are unavailable in dynamic applications, XPath provides the most reliable way to locate elements.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Designed for Dynamic and Complex DOM Structures<\/h4>\n\n\n\n<p>XPath excels in handling modern web applications where <strong>element attributes change frequently<\/strong> or DOM structures are deeply nested. It allows testers to navigate <strong>parent, child, sibling, and ancestor relationships<\/strong> with precision, making it ideal for complex UI testing scenarios.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/button[contains(text(),'Submit')]\/ancestor::form\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3. More Powerful and Expressive Than CSS Selectors<\/h4>\n\n\n\n<p>Unlike CSS selectors, XPath supports <strong>text-based matching<\/strong>, <strong>partial attribute matching<\/strong>, and <strong>upward DOM traversal<\/strong>. This makes XPath indispensable when element identification depends on visible text or contextual hierarchy.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/label[text()='Email']\/following-sibling::input\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4. Critical for Web Scraping and Data Extraction<\/h4>\n\n\n\n<p>For web scraping complex and dynamic websites, XPath enables <strong>precise data extraction<\/strong> and works seamlessly with tools like <strong>Scrapy, BeautifulSoup (lxml), and Puppeteer<\/strong>, making it a preferred choice for structured data parsing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How can we create XPath using multiple methods to locate HTML elements?<\/h3>\n\n\n\n<p>Although XPath was originally designed for <strong>XML documents<\/strong>, it is widely used today to locate <strong>HTML elements<\/strong> in modern web applications.<\/p>\n\n\n\n<p>XPath helps identify elements based on attributes, text, and DOM relationships when building automation scripts or debugging UI behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For Example consider the Sample HTML Element <\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1120\" height=\"880\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\" alt=\"\" class=\"wp-image-523313\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp 1120w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1-300x236.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1-250x196.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1-768x603.webp 768w\" sizes=\"(max-width: 1120px) 100vw, 1120px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;input \n  type=\"text\"\n  name=\"shopUrl\"\n  id=\"shopUrl\"\n  placeholder=\"http:\/\/demo.myshopify.com\"\n  class=\"border !border-red-600 hover:border-red-600 w-full py-2.5 px-3 border rounded-md text-sm text-gray-600 dark:text-gray-300 transition-all\"><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">How do we create XPath using a single attribute?<\/h3>\n\n\n\n<p>XPath can locate an element using one unique or stable attribute.<\/p>\n\n\n\n<p>This method is simple and easy to maintain.<\/p>\n\n\n\n<p>Use this approach when the attribute value does not change across builds.<\/p>\n\n\n\n<p>Using a unique and stable attribute like <code>id<\/code> for above element:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/input[@id='shopUrl']\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple<\/li>\n\n\n\n<li>Fast<\/li>\n\n\n\n<li>Preferred when the attribute is stable<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How can multiple attributes be used in XPath?<\/h3>\n\n\n\n<p>When a single attribute is not reliable, multiple attributes can be combined using <code>and<\/code>.<\/p>\n\n\n\n<p>This improves accuracy and reduces false matches.<\/p>\n\n\n\n<p>Combining multiple attributes improves accuracy:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/input[@type='text' and @name='shopUrl']\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Useful when <code>id<\/code> is not reliable<\/li>\n\n\n\n<li>Reduces false matches<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How does text-based XPath help locate elements?<\/h3>\n\n\n\n<p>Text-based XPath allows elements to be located using visible text.<\/p>\n\n\n\n<p>This is useful for buttons, links, and labels.<\/p>\n\n\n\n<p>This approach matches how users interact with the UI.<\/p>\n\n\n\n<p>The above specific input element does <strong>not contain visible text<\/strong>, so text-based XPath is <strong>not applicable here<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When should developers use contains() in XPath?<\/h3>\n\n\n\n<p>The <code>contains()<\/code> function is useful when attribute values are partially dynamic.<\/p>\n\n\n\n<p>It matches a portion of the attribute or text.<\/p>\n\n\n\n<p>Use <code>contains()<\/code> when attribute values include multiple or dynamic classes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/input[contains(@class,'border-red-600')]\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Useful for Tailwind or utility-based CSS<\/li>\n\n\n\n<li>Handles partial matches<\/li>\n<\/ul>\n\n\n\n<p>This is commonly used in modern UI frameworks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does starts-with() help with dynamic elements?<\/h3>\n\n\n\n<p>The <code>starts-with()<\/code> function matches elements where attribute values begin with a known prefix.<\/p>\n\n\n\n<p>It works well for auto-generated IDs.<\/p>\n\n\n\n<p>If IDs or classes are generated with a prefix:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/input[starts-with(@id,'shop')]\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Works even if ID becomes <code>shopUrl_123<\/code><\/li>\n\n\n\n<li>Ideal for dynamic builds<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How can parent-child relationships improve XPath reliability?<\/h3>\n\n\n\n<p>XPath can locate elements based on their position in the DOM hierarchy.<\/p>\n\n\n\n<p>This helps when elements do not have unique attributes.<\/p>\n\n\n\n<p>If above input element input is inside a form:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/form\/\/input[@name='shopUrl']\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Avoids dependency on changing IDs<\/li>\n\n\n\n<li>Uses DOM structure instead<\/li>\n<\/ul>\n\n\n\n<p><strong>Combine Attributes in XPath Expression<\/strong>: <\/p>\n\n\n\n<p>Once you have identified the unique attributes, you can combine them in an XPath expression using logical operators such as <code><strong>and<\/strong><\/code> or <code><strong>or<\/strong><\/code> to create a multi-element XPath.<\/p>\n\n\n\n<p>Using the identified attributes from the previous step, here&#8217;s an example of a multi-element XPath:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/input[@type='text' and @placeholder='Code' and @id='input_022737f0-a26a-41c7-9f39-93dfa14199ca']<\/pre>\n\n\n\n<p>This XPath will select the <code>&lt;<strong>input<\/strong>&gt;<\/code> element that matches all the specified attribute conditions.<\/p>\n\n\n\n<p><strong>Test and Validate the XPath<\/strong>: <\/p>\n\n\n\n<p>It&#8217;s crucial to test and validate the XPath expression to ensure it accurately selects the desired element. You can use browser developer tools or dedicated XPath evaluation tools to test your XPath against the target webpage.<\/p>\n\n\n\n<p>Make sure to test the XPath on various instances of the element to ensure its reliability. If the XPath fails, review the HTML structure and attributes to identify any changes or potential conflicts.<\/p>\n\n\n\n<p>Also Read:<\/p>\n\n\n\n<p><a href=\"https:\/\/webkul.com\/blog\/element-locators-in-selenium\/\" target=\"_blank\" rel=\"noreferrer noopener\">Element Locators In Selenium WebDriver<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong>: <\/h2>\n\n\n\n<p>Creating a multi-element XPath allows you to target specific elements on a webpage accurately. <\/p>\n\n\n\n<p>By identifying unique attributes and combining them in an XPath expression, you can navigate complex HTML structures and retrieve the desired information for web scraping or automation tasks.<\/p>\n\n\n\n<p>Remember to understand the HTML structure, identify unique attributes, combine them in an XPath expression, and thoroughly test and validate the XPath for reliable results.<\/p>\n\n\n\n<p> With these techniques, you&#8217;ll be well-equipped to leverage XPath effectively in your web scraping and automation projects.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Support:<\/h3>\n\n\n\n<p>That\u2019s all for the&nbsp;How to create an XPath with multiple elements&nbsp;if you have any doubts or queries regarding the extension get back to us at&nbsp;<a href=\"mailto:support@webkul.com\" target=\"_blank\" rel=\"noreferrer noopener\">support@webkul.com<\/a>&nbsp;or create a ticket at our&nbsp;<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\" target=\"_blank\" rel=\"noreferrer noopener\">HelpDesk<\/a>&nbsp;system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is XPath? XPath (XML Path Language) is a query language used to navigate, locate, and select elements or values from XML documents. In modern practice, XPath is also widely used to locate elements in HTML (DOM) structures, especially in automation testing and web scraping, where precise element identification is required. XPath was designed to <a href=\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":465,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-384321","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create an XPath with multiple elements<\/title>\n<meta name=\"description\" content=\"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create an XPath with multiple elements\" \/>\n<meta property=\"og:description\" content=\"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-21T06:29:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-22T14:06:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\" \/>\n<meta name=\"author\" content=\"Deepak Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Deepak Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\"},\"author\":{\"name\":\"Deepak Kumar\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/73b6377eefe0e14e3d7f54cb58252c6d\"},\"headline\":\"How to create an XPath with multiple elements\",\"datePublished\":\"2023-06-21T06:29:05+00:00\",\"dateModified\":\"2026-01-22T14:06:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\"},\"wordCount\":1099,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\",\"url\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\",\"name\":\"How to create an XPath with multiple elements\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\",\"datePublished\":\"2023-06-21T06:29:05+00:00\",\"dateModified\":\"2026-01-22T14:06:37+00:00\",\"description\":\"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp\",\"width\":1120,\"height\":880},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create an XPath with multiple elements\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/73b6377eefe0e14e3d7f54cb58252c6d\",\"name\":\"Deepak Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9657c9dd65bd0c509887273100d65402c0c5a9598bbfef929caff2bb8e46512b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9657c9dd65bd0c509887273100d65402c0c5a9598bbfef929caff2bb8e46512b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Deepak Kumar\"},\"description\":\"Deepak Kumar is an experienced Quality Analyst specializing in the Akeneo platform. With expertise in software testing and analyzing requirements in product information management and product data, he ensures high-quality, reliable solutions that optimize data accuracy and enhance business performance.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/deepak-kumar751\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create an XPath with multiple elements","description":"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.","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:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/","og_locale":"en_US","og_type":"article","og_title":"How to create an XPath with multiple elements","og_description":"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.","og_url":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-06-21T06:29:05+00:00","article_modified_time":"2026-01-22T14:06:37+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp","type":"","width":"","height":""}],"author":"Deepak Kumar","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Deepak Kumar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/"},"author":{"name":"Deepak Kumar","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/73b6377eefe0e14e3d7f54cb58252c6d"},"headline":"How to create an XPath with multiple elements","datePublished":"2023-06-21T06:29:05+00:00","dateModified":"2026-01-22T14:06:37+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/"},"wordCount":1099,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/","url":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/","name":"How to create an XPath with multiple elements","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp","datePublished":"2023-06-21T06:29:05+00:00","dateModified":"2026-01-22T14:06:37+00:00","description":"In this article we will learn how to create an XPath with multiple elements.Particularly useful for web scraping and automation tasks.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/htmlcontent-1.webp","width":1120,"height":880},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/xpath-with-multiple-elements\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create an XPath with multiple elements"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/73b6377eefe0e14e3d7f54cb58252c6d","name":"Deepak Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9657c9dd65bd0c509887273100d65402c0c5a9598bbfef929caff2bb8e46512b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9657c9dd65bd0c509887273100d65402c0c5a9598bbfef929caff2bb8e46512b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Deepak Kumar"},"description":"Deepak Kumar is an experienced Quality Analyst specializing in the Akeneo platform. With expertise in software testing and analyzing requirements in product information management and product data, he ensures high-quality, reliable solutions that optimize data accuracy and enhance business performance.","url":"https:\/\/webkul.com\/blog\/author\/deepak-kumar751\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/465"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=384321"}],"version-history":[{"count":13,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384321\/revisions"}],"predecessor-version":[{"id":523314,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384321\/revisions\/523314"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=384321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=384321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=384321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}