+2 votes
452 views
in Automation Testing Interview Question by (1.6k points)
edited by
What is XPATH ? How to define it ? is it based on some language ?

Please explain with an example, how to create it and for which languages we can use it ?

Thanks in advance!

1 Answer

0 votes
by (590 points)

XPath (XML Path Language) is a query language in which we can select nodes and nodes values from an XML, It also can be used for some string value or Boolean values.

In a simple way XPath is a simple address of an item in XML, Almost all browsers supports XPaths as XHTML doc. It is basically based on a tree representation to navigating and search nodes in the DOM.

Xpath Eg:

<?xml version="1.0" encoding="utf-8"?>
<xmltag>
 <projects>
   <project name="New Project" launch="2015-01-08">
     <editions>
       <edition language="English">Xpath test</edition>
       </editions>
   </project>
     </projects>
</xmltag>

How to use expressions :

/xmltag/projects/project/@name    (Selects name attributes for all projects)

/xmltag/projects/project/editions    (Selects all editions of project)  Etc…


For XHTML or HTML XPath please refer XPath for HTML Elements a good explanation of XPath creation and use.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated