XPath Tag: Enhance your skills by practicing XPath tag syntax with our given sample HTML codes and interactive exercises, designed to help you master selecting elements in HTML and XML documents.
Master XPath Tag Syntax with Hands-On Practice
XPath Exercise 1
Q1. Find Paragraph one
Q2. Find Heading 1
Q3. Find Heading 1 From DIV Tag
Q4. Find Paragraph From DIV Tag
HTML Source Code
<div>
<p>Paragraph one</p>
<h1>Heading 1 </h1>
</div>
Tips and Syntax For This Page Xpath Exercise :
Using Double Slash
Syntax : //tagname
Where tagname is the name of the HTML element you want to search for.
Here are a few examples to demonstrate how to use the double slash in XPath:
e.g :
1) //p
2) //form/div[1]/div/div[1]/div/div/input[1]
The double slash (//) in an XPath expression is used to search for elements anywhere in the document, regardless of their location in the hierarchy of elements. For example, the expression //input would select all input elements in the document, regardless of whether they are direct children of the root element or are nested several levels deep inside other elements.