Hey there! any question in your mind? Ask It Now!.

Popular Categories





What is XPATH

+2 votes
371 views
asked in Automation Testing Interview Question by tester (1,550 points)
edited by Bhartesh
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
answered by smarttester (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.

Related Questions

0 votes
1 answer 219 views
+5 votes
7 answers 14,590 views
+1 vote
1 answer 2,610 views
+1 vote
1 answer 2,239 views
+2 votes
1 answer 1,241 views
0 votes
0 answers 104 views
0 votes
0 answers 95 views

Not a Member yet?

Ask to Folks Login

My Account
873 Folks are online
83 members and 790 guest online
Your feedback is highly appreciated