|
As we know XML document is used to store and transport data. So, to access data from XML, we need something which could access each node and respective attributes data. Then the solution is XPath. XPath can be used to traverse through XML documents, to select nodes/elements, and attribute data. It is a W3C Recommendation and a flexible way of accessing different parts of an XML document. To write XPath is similar to writing path expression in your computer system to traverse to a specific location like (C:/School/Homework/assignment.docx). Consider the Following XML Document XML
XPath symbols that are used to access different parts of an XML document:
Let’s Practice XPathConsider above mentioned XML document: Select 2nd student
Select all the students with branch IT
Select all the students whose age is less than equal to 20
First 4 students
Java Code to Evaluate XPath ExpressionJava
Output: Explanation of classes and methods used in the above code:
|
Reffered: https://www.geeksforgeeks.org
Java |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |