Wednesday, October 9, 2019

XPath (XML Path)

Xpath is basically a XML Path of the selected element. Developer use HTML to write the code  for the designing of WebApplication UI  and in HTML every fields belong to some tagname.
A webpage can have multiple elements and web objects and HTML code contain the HTML description of each and every element.Before learning XPath, we should first understand XSL which stands for Extensible Stylesheet Language. It is similar to XML as CSS is to HTML .

XPath can be used to navigate through elements and attributes in an XML document.

XPath are of two types:
1. Absolute Path
2. Relative Path

Absolute Path: 
If location path starts with root node or with '/' then it is an absolute path.Lets take an example,we need to select firstname node with the class root node in the below xml.
xpath would be :  /class/student/firstname

<class>
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
</class>
  

No comments:

Post a Comment