Demo 1 : Create a student list student.xml. Write a program for a teacher to count the number of students in a class. Create a DOM tree for parsing the student.xml :
 |
Bước 1 : Tạo new Java Application trong đó có một file xml như trên |
 |
Code trong main class. |
 |
Kết quả thu được. |
Demo tại
đây.
Demo 2 : Create an XML document parser application. The application should use a DOM parser to parse an XML document containing the names of employees of an organization, ABC Apparels Ltd, and then print the names of all the employees.
 |
Bước 1 : Tạo new java application và tạo file xml như trên |
 |
Code trong main class |
 |
Kết quả.
|
Demo tại
đây
NHẬN XÉT:
-Sử dụng Dom cho phép chúng ta truy xuất sau tới từng thẻ dễ dàng hơn SAX
-Code của Dom dễ hiểu và nó có đầy đủ chức năng
Không có nhận xét nào:
Đăng nhận xét