Cả ba DLL nầy đều có trong danh sách các References mà ta có thể include khi dùng IDE Menu command Project | References... con bên trong.. Trong thí dụ dưới đây, ta Load mô
Trang 3Dùng DOM để display XML thành nhiều tầng trong
TreeView
XML, version 2.0, tiếp theo đó là
Microsoft XML, v2.6 và mới nhất là
Microsoft XML, v3.0 Cả ba DLL nầy đều có trong danh sách các References mà
ta có thể include khi dùng IDE Menu command Project | References
tự đô ̣ng parse XML data để build mô ̣t Tree gồm nhiều nodes với thứ bâ ̣c cha,
Trang 4con bên trong Dựa theo đó ta có thể display cái DOM Tree ấy trong mô ̣t TreeView để có thể hình dung đươ ̣c cấu trúc của XML data
Trong thí dụ dưới đây, ta Load mô ̣t XML
nầy còn có mô ̣t Schema file tên
LibrarySchema.xml Khi DOM load
XML file, ta có thể dă ̣n nó kiểm (validate) xem XML data có theo đúng tiêu chuẩn đòi hỏi trong Schema file
mà DOM sẽ dùng để validate data trong XML file:
<? xml version="1.0" ?>
<? xml:stylesheet type="text/xsl" href="Library.xsl" ?>
<! Copyright 2000 Wattle Software http://XMLwriter.net/
Trang 5< library xmlns="x-schema:LibrarySchema.xml" >
<! declare the Schema which defines this document < name > Northmead Local Library </ name >
< book hardback="yes" availableforloan="no" >
< title > C++ Programming for Beginners </ title >
< author >
< first-name > Claude </ first-name >
< last-name > Schwartz </ last-name >
</ author >
< callno > 005.133/C </ callno >
< online_url > http://library/online_books/005133C.html </ online_url </ book >
< journal series="XML Users Journal" >
< title > XML Users Journal August 1999 </ title >
< date > 1999-08-01 </ date >
< callno > 005.133/C </ callno >
</ journal >
< video >
< title > Titanic </ title >
< director >
< name > James Cameron </ name >
</ director >
< callno > 643.11/T </ callno >
Trang 7Kỹ thuâ ̣t XML
Vovisoft © 2000 All rights reserved.
Last Updated: 10 July 2001 Webmaster