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

Popular Categories





What is XPATH

+2 votes
412 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

+5 votes
7 answers 14,864 views
+1 vote
1 answer 3,617 views
+1 vote
1 answer 2,344 views
+2 votes
1 answer 1,403 views
0 votes
0 answers 114 views
+4 votes
3 answers 163 views
+7 votes
1 answer 524 views
+5 votes
1 answer 154 views
asked in Programming by mannu (990 points)

Not a Member yet?

Ask to Folks Login

My Account
500 Folks are online
0 members and 500 guest online
Your feedback is highly appreciated