Thứ Hai, 28 tháng 7, 2014

Use DOM to work with XML

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 project



Bước 2: Tạo file student.xml

Bước 3: Viết code cho file chạy chương trình


Kết quả:


Demo: https://drive.google.com/file/d/0B-EFzewQLSMDX0tUTldZc3VGSEk/edit?usp=sharing

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 project



Bước 2: Tạo file employees.xml


Bước 3: Viết code cho file chạy chương trình

Kết quả:

Demo https://drive.google.com/file/d/0B-EFzewQLSMDa0dRRWxYdk1MR0E/edit?usp=sharing

Nhận xét:

-DOM có đầy đủ các chưc năng hơn SAX
-Code rất chặt chẽ, dễ hiểu
-Tính năng bảo mật sẽ đước nâng cao hơn
-DOM có thể truy xuất vào bất kỳ phần nào trong file XML

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

Đăng nhận xét