Javatpoint Logo
Javatpoint Logo
XPath Interview Questions

XPath Interview Questions

There is given XPath interview questions and answers that has been asked in many companies. Let's see the list of top XPath interview questions.

1) What is XPath?

XPath is an important and core component of XSLT standard. It is used to traverse the elements and attributes in an XML document. For more: Click here

2) What are the main features of XPath?

  • XPath is a major element in the XSLT standard.
  • It is syntax for defining parts of an XML document.
  • XPATH stands for XML Path Language.
  • It is used for navigating in XML documents.
  • It can be used to query data from XML documents.
  • It uses path expressions to navigate in XML documents.
  • XPATH expressions are case sensitive.

3) What do you mean by XPath expressions?

XPath defines a pattern or path expression to select nodes or node sets in an XML document. These patterns are used by XSLT to perform transformations. XPath specifies seven types of nodes that can be output of the execution of the XPath expression.

  • Root
  • Element
  • Text
  • Attribute
  • Comment
  • Processing Instruction
  • Namespace

4) What do you mean by XPath nodes?

A node is an XML document which is specified in the tree structure.

5) How many types of nodes in XPath?

There are seven kinds of nodes in XPath:

  • Element
  • Attribute
  • Text
  • Namespace
  • Processing-instruction
  • Comment
  • Document nodes

6) What is XPath syntax?

The XPath syntax specifies the different nodes, path expressions, path notation, predicates and URLs which are used to define the XML document.

7) What are the different types of location paths in XPath?

There are two types of location paths used to specify the location of node in XML documents. These paths are absolute or relative path.

8) What is the meaning of absolute path in XPath?

An absolute path starts with root node or with '/'.

For Example:

/company/employee- It will select employee nodes within class root node.

For more information: click here

9) What do you mean by XPath relative path?

A path is known as relative path if it is started with the node that we've selected. For more information: click here

10) What do you mean by XPath Axes?

XPath axes are used to identify elements by their relationship like parent, child, sibling, etc. in the same manner like path defines the location of the node. For more information: click here

11) What do you mean by XPath operators?

XPath defines operators and functions on nodes. An XPath expression returns either a node-set, a string, a Boolean, or a number.

12) What are the different types of operators in XPath?

XPath operators can be categorized in different category according to their property. Following are the different types of XPath operators:

  • Comparison Operators
  • Boolean Operators
  • Number Functions/Operators
  • String Functions
  • Node Functions/Operators

For more information: click here

13) What do you understand by XPath comparison operator?

XPath comparison operator is used to compare one value to another. There are different type of comparison operators:

  • =
  • !=
  • <
  • >
  • <=
  • >=

For more information: click here

14) What do you mean by Xpath Boolean operatos?

Boolean operators are simple words AND, OR, NOT etc. used to combine or exclude keywords. They connect your search words together to either concise or expand your set of results. For more information: click here

15) What do you understand by XPath number operators?

The XPath number operators are used to do mathematical operations on different keywords. There are five number operators in XPath.

  • +
  • -
  • *
  • div
  • mod

For more information, go to the link click here

16) What do you understand by XPath number functions?

In XPath, number functions are used to fetch the different type of values from the expressions. For example, ceiling value, floor value etc.

There are four types of number functions in XPath:

  • ceiling()
  • floor()
  • round()
  • sum()

For more information, go to the link click here

17) What do you know by XPath string functions?

The XPath string functions specify some rules which are used to get strings according to your preferences.

For more information, go to the link click here

18) How to define relationship among nodes?

There are following types of nodes in XPath. These nodes are related to each other to form a tree like structure. These nodes are:

  • Parents
  • Children
  • Siblings
  • Ancestors
  • Descendents

For example:

19) What are the different standard functions in XPath?

XPath has more than 101 build-in functions. These built-in functions are used in Boolean values, string values, numeric values, date and time comparison, sequence manipulation etc.

20) What are the different XPath Axes?

XPath axes are used to set relation of current node with another node. A list of XPath axes to set relation with other nodes are:

  • ancestor: It is used to get all ancestor (parent, grandparent etc) of current node.
  • ancestor-or-self: It is used to get all ancestors (parent, grandparent, etc.) of the current node and also the current node.
  • attribute: It is used to get all attributes of the current node.
  • child : It is used to retrieve all children of the current node.
  • descendant: It is used to get all descendants (children, grandchildren, etc.) of the current node.
  • namespace: It is used to get all namespace nodes of the current node.
  • preceding: It is used to get everything in the document that is comes before the start tag of the current node.

21) What is an atomic value in XPath?

Nodes that has no parent node or child node are called as Atomic values.

For example:

Here, Rashmi Sharma is an atomic value.

22) What happens about the presence of the top-level element in XSLT?

  • The top-level elements don't have any effect on the behaviour of XSLT elements.
  • The functions that are defined with it also don't have any affect in the document.
  • The top-level elements are not permitted to be used by specifying the xsl:apply templates.
  • XSLT process is provided to ignore the top-level elements and ignore some of it if an error occurs.
  • XSLT top-element element doesn't recognize the namespace URI and can be provided using other sources.

You may also like:

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA