Phần chÃnh cá»§a chương trình nằm trong Sub Form_Load như liệt ra dưới đây. Bạn có thể xem listing và giải thÃch vá» cách transform Library.xml dá»±a trên Library.xsl trong bà i [Chỉ thà nh viên má»›i nhìn thấy Link. ]
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