Note that due to limitations of the treeview you will receive errors if the treeview node count exceeds 32767. Also, note that this code is not supported in the 64-bit version of Access 2010 or 2013 due to the use of the Common Controls of MSComCtl32.ocx.
Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the CXMLTreeView class. |
SourceFile | Property | Get the path and name of the XML source file. |
Treeview | Property | Set the treeview to populate with the XML data. |
Class_Initialize | Initialize | Initialize the class. |
DOMNodeToTreeViewNode | Method | Convert the passed node to the Treeview data structure. |
LoadTreeview | Method | Load the XML document into the treeview. |
FormatAttributes | Private | Get a list of the node's format attribute names and values. |
FormatNodeString | Private | Format a node into string data depending on its attributes. |
mxmlDocument_OnDataAvailable | Private | Event raised by the XML parser when data is available. |
mxmlDocument_OnReadyStateChange | Private | Event raised by the XML parser when the Ready State changes. |
' To use this example: ' 1. Create a new form. ' 2. Create the following command button: cmdLoadXML ' 3. Create the following textbox: txtSourceFile ' 4. Create the following Treeview: tvwTest ' 5. Paste the entire contents of this module into the new form's module. ' This example assumes that the sample files are located in the folder named by the following constant. Private Const mcstrSamplePath As String = "C:\Total Visual SourceBook 2013\Samples\" Private Sub cmdLoadXML_Click() ' Create an instance of our class Dim MyXML As New CXMLTreeView With MyXML ' Get the source file .SourceFile = Me.txtSourceFile.Value ' Set our treeview to the class Set .Treeview = Me.tvwTest.Object ' Load the data .LoadTreeview End With End Sub Private Sub Form_Load() ' Set up the form cmdLoadXML.Caption = "LoadXML" ' Set a default file txtSourceFile.Value = mcstrSamplePath & "ADOXMLTEST.XML" ' Set up our treeview With tvwTest .Indentation = 0.5 .LineStyle = tvwRootLines .Style = tvwTreelinesPlusMinusPictureText End With End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP