{"id":44570,"date":"2017-04-26T15:00:45","date_gmt":"2017-04-26T12:00:45","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=44570"},"modified":"2017-04-26T14:38:45","modified_gmt":"2017-04-26T11:38:45","slug":"get-xpath-html-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/","title":{"rendered":"Get Xpath From Html Example"},"content":{"rendered":"<p>In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this.<\/p>\n<h2>1. Introduction<\/h2>\n<p>XPath is a W3C recommendation. It can be used to navigate through elements and attributes in an XML document. It is a syntax for defining parts of an XML document. It uses path expressions to select nodes or node-sets in an XML document.\u00a0These path expressions look very much like the expressions you see when you work with a traditional computer file system.\u00a0XPath expressions can be used in JavaScript, Java, XML Schema, PHP, Python, C and C++, and lots of other languages. It contains a library of standard functions.<\/p>\n<p>In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document nodes.\u00a0XML documents are treated as trees of nodes. The topmost element of the tree is called the root element.\u00a0Atomic values are nodes with no children or parent.<\/p>\n<p>HTML is the standard markup language for creating Web pages. It\u00a0stands for Hyper Text Markup Language and\u00a0describes the structure of Web pages using markup.\u00a0HTML elements are the building blocks of HTML pages and\u00a0are represented by tags.\u00a0HTML tags label pieces of content such as &#8220;heading&#8221;, &#8220;paragraph&#8221;, &#8220;table&#8221;, and so on.\u00a0Browsers do not display the HTML tags, but use them to render the content of the page.\u00a0Everything you see on the page is an element. Every field, link, image, text and many things you don\u2019t see are all elements. An element is equivalent to a tag in HTML, though there can be elements on a page that did not come from the HTML source<\/p>\n<h2>2. Find XPath using Chrome<\/h2>\n<p>In this section we will learn how to use Chrome to find an XPath for an HTML element.\u00a0You don&#8217;t need any extensions installed to be able to find the XPath information of website elements when you&#8217;re using Chrome. Open the website you want to inspect in Chrome.\u00a0Press F12 to open the website inspector.<\/p>\n<p><figure id=\"attachment_44707\" aria-describedby=\"caption-attachment-44707\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-F12.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44707\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-F12.jpg\" alt=\"\" width=\"860\" height=\"325\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-F12.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-F12-300x113.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-F12-768x290.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44707\" class=\"wp-caption-text\">Figure 1. Chrome F12<\/figcaption><\/figure><\/p>\n<p>This will appear on the right side of the window.\u00a0Click the element inspector button. You&#8217;ll find this in the top-left corner of the website inspector panel. The button looks like a box with a mouse cursor pointing at it. Click the element on the website that you want to inspect. You&#8217;ll see the elements of the site highlight as you move your cursor over them.<\/p>\n<p><figure id=\"attachment_44708\" aria-describedby=\"caption-attachment-44708\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Highlight.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44708\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Highlight.jpg\" alt=\"\" width=\"860\" height=\"421\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Highlight.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Highlight-300x147.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Highlight-768x376.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44708\" class=\"wp-caption-text\">Figure 2. Chrome Highlight<\/figcaption><\/figure><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Right-click the highlighted code in the inspector panel. When you click an element with the inspector, the relevant code will highlight automatically in the inspector panel on the bottom of the window. Right-click the highlighted code.\u00a0Select &#8220;Copy&#8221; =&gt; &#8220;Copy XPath.&#8221;<\/p>\n<p><figure id=\"attachment_44709\" aria-describedby=\"caption-attachment-44709\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Copy-XPath.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44709\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Copy-XPath.jpg\" alt=\"\" width=\"860\" height=\"365\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Copy-XPath.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Copy-XPath-300x127.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Copy-XPath-768x326.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44709\" class=\"wp-caption-text\">Figure 3. Chrome Copy XPath<\/figcaption><\/figure><\/p>\n<p>This will copy the element&#8217;s XPath information to your clipboard.\u00a0Note that this just copies the minimal XPath information. Firebug for Firefox can give you the full XPath information.<\/p>\n<h2>3. Find XPath using XPather<\/h2>\n<p>In this section we will see how we can use Google Chrome to find the XPath of an HTML element. We will make use of an extension called XPather.\u00a0Google Chrome Extensions are browser extensions that modify the Google Chrome browser. These extensions are written using web technologies like HTML, JavaScript, and CSS. Google Chrome Extensions are downloadable through the Chrome Web Store (formerly the Google Chrome Extensions Gallery).<\/p>\n<h3>3.1 Add XPather extension to Chrome<\/h3>\n<p>In this section we will see how to add the XPather extension to Google Chrome. Open Chrome and click on the three vertical dots on the top right corner:<\/p>\n<p><figure id=\"attachment_44571\" aria-describedby=\"caption-attachment-44571\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-settings.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44571\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-settings.jpg\" alt=\"\" width=\"860\" height=\"115\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-settings.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-settings-300x40.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-settings-768x103.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44571\" class=\"wp-caption-text\">Figure 4. Chrome Settings<\/figcaption><\/figure><\/p>\n<p>Go to <em>Settings<\/em> and on the left hand side click <em>Extensions.\u00a0<\/em>Now go to the bottom of the screen and click &#8216;Get more extensions&#8217;. A new window will be open where you will be able to download more extensions from\u00a0Chrome Web Store. Enter <em>XPather<\/em> in the search window and press Enter:<\/p>\n<p><figure id=\"attachment_44572\" aria-describedby=\"caption-attachment-44572\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Web-Store.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44572\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Web-Store.jpg\" alt=\"\" width=\"860\" height=\"501\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Web-Store.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Web-Store-300x175.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Chrome-Web-Store-768x447.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44572\" class=\"wp-caption-text\">Figure 5. Chrome Web Store<\/figcaption><\/figure><\/p>\n<p>Click on <em>ADD TO CHROME<\/em> button:<\/p>\n<p><figure id=\"attachment_44573\" aria-describedby=\"caption-attachment-44573\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/XPather-extension.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44573\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/XPather-extension.jpg\" alt=\"\" width=\"860\" height=\"234\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/XPather-extension.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/XPather-extension-300x82.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/XPather-extension-768x209.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44573\" class=\"wp-caption-text\">Figure 6. XPather extension<\/figcaption><\/figure><\/p>\n<p>On the new pop-up click on the Add Extension button. Chrome will install the extension. To check if the extension was successfully installed check for the little magnifier symbol surrounded by a square box on the top right corner of Chrome.<\/p>\n<h3>3.2 Features of XPather<\/h3>\n<ul>\n<li>XPather lets you\u00a0search by evaluating XPath using jQuery.<\/li>\n<li>The results are highlighted instantly.<\/li>\n<li>The matched nodes contents are available in the sidebar.<\/li>\n<li>It lets you\u00a0find matched node on page by clicking it in sidebar.<\/li>\n<li>There are shortcuts for functions and attributes.<\/li>\n<\/ul>\n<p><strong>Keyboard shortcuts<\/strong><\/p>\n<p>Alt+X: toggle XPather<br \/>\nAlt+Shift+X: toggle XPather Sidebar (when XPather is active)<br \/>\nAlt+Z: autocomplete XPather input<\/p>\n<p>All shortcuts are customizable using &#8220;Keyboard Shortcuts&#8221; option located on the bottom of Chrome extensions page (chrome:\/\/extensions).<\/p>\n<h2>4. Use Firebug<\/h2>\n<p>In this section we will learn how to use Firefow to find an XPath of an HTML element. You can find XPath information for website elements using most browsers&#8217; developer tools. Firebug for Firefox allows you to copy XPath information directly to your clipboard.\u00a0Firebug is a web inspector add-on for Firefox<\/p>\n<h3>4.1 Install Firebug<\/h3>\n<p>First we need to install Firebug Add-on. Open Firefox and go to\u00a0<a href=\"https:\/\/addons.mozilla.org\/en-GB\/firefox\/addon\/firebug\/\">Add-ons<\/a>. Click on &#8216;Add to Firefox&#8217; button.<\/p>\n<p><figure id=\"attachment_44697\" aria-describedby=\"caption-attachment-44697\" style=\"width: 859px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-Add-on.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44697\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-Add-on.jpg\" alt=\"\" width=\"859\" height=\"559\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-Add-on.jpg 859w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-Add-on-300x195.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-Add-on-768x500.jpg 768w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><\/a><figcaption id=\"caption-attachment-44697\" class=\"wp-caption-text\">Figure 7. Firebug Add-on<\/figcaption><\/figure><\/p>\n<p>Firefox will install the Firebug. Once that is installed you will see a big icon in to top right hand corner:<\/p>\n<p><figure id=\"attachment_44698\" aria-describedby=\"caption-attachment-44698\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-icon.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44698\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-icon.jpg\" alt=\"\" width=\"860\" height=\"85\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-icon.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-icon-300x30.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-icon-768x76.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44698\" class=\"wp-caption-text\">Figure 8. Firebug icon<\/figcaption><\/figure><\/p>\n<p>Now open the website that you want to inspect. You can use Firebug to inspect any element on a website to find the XPath.\u00a0Click the Firebug button. You&#8217;ll find this in the upper-right corner of the window. This will open the Firebug panel at the bottom of the Firefox window.<\/p>\n<p><figure id=\"attachment_44699\" aria-describedby=\"caption-attachment-44699\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-panel.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44699\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-panel.jpg\" alt=\"\" width=\"860\" height=\"229\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-panel.jpg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-panel-300x80.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Firebug-panel-768x205.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-44699\" class=\"wp-caption-text\">Figure 9. Firebug Panel<\/figcaption><\/figure><\/p>\n<p>Click the element inspector button. You&#8217;ll find this in the top row of buttons in the Firebug panel at the bottom of the window, directly to the right of the Firebug Options button. It looks like a box with a mouse cursor pointing at it.\u00a0Click the web page element that you want to inspect. As you move your cursor over the web page, you&#8217;ll see different elements get highlighted. Click the one that you want to find the XPath for.\u00a0Right-click the highlighted code in the Firebug panel. When you click an element in a web page, it&#8217;s related code will be highlighted in the Firebug panel at the bottom of the window. Right-click this highlighted code.\u00a0Select &#8220;Copy XPath&#8221; from the menu. This will copy the element&#8217;s XPath information to your clipboard.\u00a0If you select &#8220;Copy Minimal XPath,&#8221; just the basic XPath information will be copied.<\/p>\n<h2>5. Conclusion<\/h2>\n<p>In this article we learned about XPath and it&#8217;s various usages. We also discussed what is an HTML and where it is used. We saw how we can grab the XPath of an HTML element using browsers like Chrome and Firefox. Similar kind of functionality is also present in other browsers as well e.g. Safari, IE etc<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath is a W3C recommendation. It can be used to navigate through elements and attributes in an XML document. It is a syntax for defining parts &hellip;<\/p>\n","protected":false},"author":34,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[1022,256],"class_list":["post-44570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xpath","tag-html","tag-xpath-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get Xpath From Html Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Xpath From Html Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-26T12:00:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mohammad Meraj Zia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohammad Meraj Zia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\"},\"author\":{\"name\":\"Mohammad Meraj Zia\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\"},\"headline\":\"Get Xpath From Html Example\",\"datePublished\":\"2017-04-26T12:00:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\"},\"wordCount\":1232,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"html\",\"xpath\"],\"articleSection\":[\"XPath\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\",\"name\":\"Get Xpath From Html Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2017-04-26T12:00:45+00:00\",\"description\":\"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"xml\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"XPath\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/xpath\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Get Xpath From Html Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\",\"name\":\"Mohammad Meraj Zia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"caption\":\"Mohammad Meraj Zia\"},\"description\":\"Senior Java Developer\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Xpath From Html Example - Java Code Geeks","description":"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath","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:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/","og_locale":"en_US","og_type":"article","og_title":"Get Xpath From Html Example - Java Code Geeks","og_description":"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-04-26T12:00:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Mohammad Meraj Zia","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mohammad Meraj Zia","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/"},"author":{"name":"Mohammad Meraj Zia","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed"},"headline":"Get Xpath From Html Example","datePublished":"2017-04-26T12:00:45+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/"},"wordCount":1232,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["html","xpath"],"articleSection":["XPath"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/","name":"Get Xpath From Html Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2017-04-26T12:00:45+00:00","description":"In this example we will learn how to find the XPath of a given element in HTML. We will try to use different tools to achieve this. 1. Introduction XPath","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/get-xpath-html-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"xml","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/"},{"@type":"ListItem","position":5,"name":"XPath","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/xpath\/"},{"@type":"ListItem","position":6,"name":"Get Xpath From Html Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed","name":"Mohammad Meraj Zia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","caption":"Mohammad Meraj Zia"},"description":"Senior Java Developer","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=44570"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44570\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=44570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=44570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=44570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}