Trang chủ Liên hệ Sơ đồ  
 
Trang chủ 1001 Mẫu Web Thiết kế Web Lập trình Quản trị Web Web & Hosting Hình nền Blog Icon & Logo
 
 
     
       Mẫu web mới nhất
Xem | ID: 5076
Xem | ID: 1003235
HƯỚNG DẪN
Tạo HTML từ XML và XSL
(Thứ Năm, 24/12/2009-10:39 AM)
Trong trường hợp ấy nếu bạn View Source của Webpage bạn chỉ đọc đuợc XML source mà thôi. Có thể bạn sẽ thắc mắc sao không thấy cái HTML source là kết quả của quá trình Tranform XML.
Trong chương trình VB6 trình bày tại đây bạn sẽ thấy cách dùng DOM (Document Object Model) của MSXML để thực hiện công việc tương đương với IE 5.5 và save kết quả HTML thành một Webpage . Webpage nầy có thể được display, độc lập với XML, bằng bất cứ WebBrowser nào.Thật ra, ActiveX MSXML mà ta dùng cho VB6 là của IE 5.5 khi ta Project | Reference "Microsoft XML, v3.0".

Chương trình mẫu

Bạn có thể download chương trình mẫu tại đây để xem cách thảo chương rất đơn giản.

Phần chính của chương trình nằm trong Sub Form_Load như liệt ra dưới đây.
Private Sub Form_Load() 
Dim HTMLCode As String
' Need to Project | References "Microsoft XML, v3.0" to use DOM
Dim myXMLDoc As New MSXML2.DOMDocument30
Dim myXSLDoc As New MSXML2.DOMDocument30
' Need to Project | References "Microsoft Script Runtime" to use
' FileSystemObject and TextStream
Dim Fs As FileSystemObject
Dim TS As TextStream
' Display the XML file in a listbox
PopulateListBoxFromFile LstXML, "Library.xml", False
' Display the XSL file in a listbox
PopulateListBoxFromFile lstXSL, "Library.xsl", False
' Load the XML file
myXMLDoc.Load App.Path & "\Library.xml"
' Load the XSL file
myXSLDoc.Load App.Path & "\Library.xsl"
' Transform XML by XSL to give HTML
HTMLCode = myXMLDoc.transformNode(myXSLDoc)
' Now Write the resultant HTML to file
' Create a FileSystem Object
Set Fs = CreateObject("Scripting.FileSystemObject")
' Open TextStream for Output
Set TS = Fs.OpenTextFile(App.Path & "\Library.htm", ForWriting, False, TristateUseDefault)
TS.Write HTMLCode ' Write the whole HTML string in one stroke
TS.Close ' Close the Text Stream
Set Fs = Nothing ' Dispose FileSystem Object
' Display the HTML file in a listbox
PopulateListBoxFromFile lstHTML, "Library.htm", False
End Sub


Theo Vovisoft

   "Tìm hiểu Vũ trụ mênh mông huyền bí"     www.bachkhoatrithuc.vn

 In bài này  Gửi bài viết
    [ Các bài mới ]
    [ Các bài đã đăng ]

    Download phần mềm 
    được ưa dùng  nhất