Sie sind auf Seite 1von 4

INTRODUCTION OF XPATH

SAYANTAN TARAFDAR
Introduction of XPath
XPath is a major element in the XSLT standard. XPath can be used to navigate through elements
and attributes in an XML document. XPath is a syntax for defining parts of an XML
document. XPath uses path expressions to navigate in XML documents. XPath contains a library of
standard functions.
XSL (eXtensible
Stylesheet
//TAG_NAME[@ATTRIBUTE_NAME=‘VALUE’] Language) is a
styling language
for XML.

ELEMENTS EXPLANATION
// Current Node
Tag Name Current tag ex div input
@ Select attribute
Attribute name Name/id/class
value Value assigned to it
www.studysimple.in
Types of Xpath
XPath is mainly of two types or better say can be used in two ways.

ABSOLUTE XPATH RELATIVE XPATH

Complete path is provided from Complete path is provided from


root of the element to desired root of the element to desired
element element

/html/body/div[5]/div[2]/h2[1] //input[@id='answers']/h2[1]/a[1]

Starts with single slash “/” that Starts with a double slash “//” that
means starting to search from the means it can start to search
root. anywhere in the DOM structure.

www.studysimple.in
Important Terminology used in Xpath
Will discuss some important terminology which will help to find xpath

<input id=“user-message” class=“form-control”/>

CONTAINS //input[contains(@id, ‘er-messa’)]

STARTS WITH //input[starts-with(@id, ‘user’)]

OR //*[@id=’user-message’ and @class=’form-control’]

…many more

www.studysimple.in

Das könnte Ihnen auch gefallen