Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: filling treeview from xml file, but only certain tags

From: minimalniemand <Michael.Niemand@----------.--->
To: NULL
Date: 8/1/2008 8:16:00 AM
I had to rewrite it this way:

Sub InitializeTree(ByVal src As String)

xml.Load (src)
xml.setProperty "SelectionLanguage", "XPath"
Call AddNodes(Me!ocxTreeView.Nodes,
xml.documentElement.selectNodes("*"))

End Sub

Sub AddNodes(ByVal treeNodes As Nodes, ByVal xmlNodes As
MSXML2.IXMLDOMNodeList)

  For Each x1 In xmlNodes
    Select Case x1.tagName
        Case "CLAUSE"
            Dim treeNode As Node
            Set treeNode = treeNodes.Add(, , ,
x1.selectSingleNode("OPTEXT").Text)
            treeNodes.Add (treeNode)
            Call AddNodes(treeNode.Nodes, x1.selectNodes("ITEMS/*"))
        Case "ITEM"
            treeNodes.Add
(treeNodes.Add(x1.selectSingleNode("ITEXT").Text))
    End Select
  Next
End Sub

But its not yet working. The Nodes Property of treeNode does not exist
in VB, what exactly is it? Is it a list of all children under
treeNode? there aint such a collection I'm afraid


On 1 Aug., 16:17, Martin Honnen <mahotr...@yahoo.de> wrote:
> minimalniemand wrote:
> > the XML file for the example can be found here:http://mad-scientists.co.uk/micha/example.xml
>
> I don't program with classic VB so here is an example with VB.NET 2005:
>
>      Sub InitializeTree(ByVal treeView As TreeView, ByVal src As String)
>          Dim doc As New XmlDocument()
>          doc.Load(src)
>          AddNodes(treeView.Nodes, doc.DocumentElement.SelectNodes("*"))
>      End Sub
>
>      Sub AddNodes(ByVal treeNodes As TreeNodeCollection, ByVal xmlNodes
> As XmlNodeList)
>          For Each childElem As XmlNode In xmlNodes
>              Select Case childElem.LocalName
>                  Case "CLAUSE"
>                      Dim treeNode As New
> TreeNode(childElem.SelectSingleNode("OPTEXT").InnerText)
>                      treeNodes.Add(treeNode)
>                      AddNodes(treeNode.Nodes,
> childElem.SelectNodes("ITEMS/*"))
>                  Case "ITEM"
>                      treeNodes.Add(New
> TreeNode(childElem.SelectSingleNode("ITEXT").InnerText))
>
>              End Select
>          Next
>
>      End Sub
>
> It is then called as
>    InitializeTree(TreeView1, "..\..\XMLFile1.xml")
> where TreeView1 is the tree view you want add nodes to and the second
> argument is a string with the path to the XML file.
>
> I realize you are not using .NET but classic VB and MSXML so here are
> some hints how to translate the .NET XML DOM properties and methods to
> MSXML and classic VB:
> 1) use selectNodes instead of SelectNodes
> 2) use selectSingleNode instead of SelectSingleNode
> 3) use text instead of InnerText
> 4) use MSXML2.DOMDocument30 instead of XmlDocument
> 5) make sure you call
>      xmlDocument.setProperty "SelectionLanguage", "XPath"
>     on your MSXML DOM document before you use selectNodes/selectSingleNode
>
> --
>
>         Martin Honnen
>        http://JavaScript.FAQTs.com/



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent