Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

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.

LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud