Chủ Nhật, 3 tháng 8, 2014

Using NodeIterator to read XML file

Module 6:Create an XML document containing the employee details of an organization. Then create an application, which uses the DOM parser to parse the XML document into a DOM tree and traverses through it. The application should implement the TreeWalker interface to traverse all the nodes present in the DOM tree and print the value of the nodes.

B1:Tạo mới java application,gồm các components sau:



B2:Tạo file Empoyess.xml có nội dung như sau:



B3:Triển khai code trong hàm main
Khai báo 1 DOM,và yêu cầu phải sử dung DOM


Hiển thị ra danh sách list,sử dụng NodeIterator

Kết quả:



Nhận xét:  sử dụng NodeIterator giúp cho việc truy xuất tới các thẻ 1 cách dễ dàng,và lấy thông tin từ các thẻ đó
-DOM có nhiều tính năng vượt trội hơn hẳn so với SAX




Không có nhận xét nào:

Đăng nhận xét