Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

What is the difference between ‘/’ and ‘//’ in XPath?

The following is the difference between the forward slash (/) and double forward slash (//) in XPath:

  • Single Forward Slash (/):
  • The single forward slash is used to specify the immediate child of the current node. For example, if we have an XML document with a root element called "books," each book is represented by a component called "book." The XPath expression "/books/book" would select all the immediate child elements called "book" of the "books" element.

  • Double Forward Slash (//):
  • The double forward slash is used to specify all descendants (children, grandchildren, great-grandchildren, etc.) of the current node, regardless of their level in the hierarchy. For example, the XPath expression "//book" would select all elements called "book" at any level of the XML document.

To conclude, the single forward slash (/) selects only the immediate child elements, while the double forward slash (//) selects all descendants of the current node, regardless of their level.


You can also use this free XPath Tester tool that is designed to allow users to test and evaluate XPath expressions or queries against an XML document. It helps ensure that the XPath queries are accurate and return the expected results.

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free