BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
XML DOM
The Joy of SAX
The Understanding XML DOM Game
Programming the SAX2 interfaces from Visual Basic
Integration with SAX
Responding to SAX Events in JDOM
Firing SAX events from JDOM
Introduction to MSXML and SAX2
Information on the MinML SAX parser
Python & XML
The XML HTTPRequest
The XML DOMParseError
The XML DOMProcessingInstruction
The XML DOMEntity
The XML DOMDocumentType
The XML DOMAttribute
The XML DOMCDATASection
The XML DOMNamedNodeMap
The XML DOMNodeList
The XML DOMNode
The XML DOMElement
<< XHTML
XmlSerializer >>
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/26/2000
Times viewed :2388

 

Loading a Microsoft TreeView from an XML DOM document

by Mark Wilson

 

Download some source code now!

Load the DOM document into a DOM object called objPeopleRoot. Create a Element object called objPersonElement (of the type IXMLDOMElement).

Then use this code to iterate through the elements in the DOM object:

For Each objPersonElement In objPeopleRoot.childNodes
populateTreeWithChildren objPersonElement
Next

As you can see, the code above calls a sub routine called populateTreeWithChildren, which is listed below. The code assumes you have a MS VB6 Treeview called tvwPeople on the form.

Private Sub populateTreeWithChildren(objDOMNode As IXMLDOMElement)

'*****************************************************
' Purpose: For each parent node created on the TreeView,
' drill down into the DOM Element that has
' been passed in and populate the TreeView with
' these the DOMElement childNodes.
' Inputs:
' objDOMNode: the current child node from the docElement
' property of the DOMDocument
'*****************************************************

Dim objNameNode As IXMLDOMNode
Dim objAttributes As IXMLDOMNamedNodeMap
Dim objAttributeNode As IXMLDOMNode
Dim intIndex As Integer

Dim tvwElement As Node
Dim tvwChildElement As Node

'we're adding the elements main child as the name of this
'section - which we have chosen as the "NAME" element.
'Use the method selectSingleNode to return the first node
'that it finds with the nodeName of "NAME"
Set objNameNode = objDOMNode.selectSingleNode("NAME")

'Add the "NAME" element's parent node nodeName and its
'value to the TreeView
Set tvwElement = tvwPeople.Nodes.Add(1, tvwChild)
tvwElement.Text = objNameNode.parentNode.nodeName & ": " _
& objNameNode.nodeTypedValue

'Add the ID of the node to the TreeView node’s tag property
'the element node is holding the id attribute that we want
'to store in the tag, as an identity reference. We
'therefore need to get hold of this node to get its value
Set objAttributes = objDOMNode.Attributes

'check that there are attributes.
If objAttributes.length > 0 Then

'we know that we've named our id reference as
''PERSONID', therefore tell the NameNodeListMap to get
'this node by using the getNamedItem method
Set objAttributeNode = objAttributes.getNamedItem("PERSONID")

'store this value in the tag of the TreeView
tvwElement.Tag = objAttributeNode.nodeValue
End If


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




Chicago Web Site Design
international conference call
it help desk
Christian Dior sunglasses
air freshener
odor remover


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP