Thursday, August 14, 2014

Use Xpath

Demo: In an organization, five hundred employees are working. Out of which some are apprentices. The Delivery Unit Head of that organization gave you the responsibility to develop a software, with which you can find the details of apprentices. Use the below files to develop the application: 
1. The EmployeeDatabase.xml file holds the data of all employees. 
2. Use XPath expressions. 
In this application, the apprentices are defined in the trainee namespace while all other employees are defined in the default namespace. This application should count the number of apprentices and print their details on the user console.

Bước 1: Tạo new project



Bước 2: Tạo file EmployeeDatabase.xml có sử dụng Namespace


Bước 3: Viết code cho file main
code tạo Document kêt nối XML


code kiểm tra Namespace


Code tạo Xpath


Kết quả:


Demo: XpathDemo

Nhận xét :
-Hiện nay, Xpath có vai trò rất quan trọng trong quá trình trao đổi thông tin, dữ liệu
-Sử dụng Xpath, ta sẽ dễ dàng truy cập vào các node trong XML bằng cách viết các câu lệnh đơn giản và đặt điều kiên trong các câu lệnh
-Cú pháp khai báo cũng khá đơn giản và ngắn gọn
-Xpath cho phép ta chọn lựa những thông tin, dữ liệu nào mà ta muốn chuyển

No comments:

Post a Comment