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


Home->Practice 1

  Next Exercise >>
Please Follow Step 1: Read XPath Question >>Step 2: Check HTML Source Code >>Step3: Enter XPath Syntax in O/P Box

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>
        

XPath O/P Box

Enter XPath Syntax here:   

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.

We would love to hear your thoughts, suggestions, concerns or problems with anything so we can improve. Request you to please use Social Media button in Right Side for this website growth.