在form上添加button 和 text(设置multiLine=true和垂直滚动条)
Private Sub Command1_Click() Dim xmldoc As DOMDocument Dim nodes As IXMLDOMNode Dim cnodes As IXMLDOMNode
Set xmldoc = New DOMDocument xmldoc.Load App.Path + "\test.xml" If xmldoc.documentElement Is Nothing Then Exit Sub End If Set nodes = xmldoc.documentElement.childNodes(0) '第一个节点 Text1.Text = "" For i = 0 To nodes.childNodes.length - 1 ''第一个节点的下一层节点 (2层) Set cnodes = nodes.childNodes.Item(i) For Each pp In cnodes.childNodes '3层 If LCase(pp.Attributes.getNamedItem("name").nodeValue) = "name" Then '节点名为name Text1.Text = Text1.Text + CStr(pp.Text) + "," End If If LCase(pp.Attributes.getNamedItem("name").nodeValue) = "fullname" Then Text1.Text = Text1.Text + CStr(pp.Text) + "," End If If LCase(pp.Attributes.getNamedItem("name").nodeValue) = "description" Then Text1.Text = Text1.Text + CStr(pp.Text) + vbCrLf End If Text1.Refresh Next Next
End Sub
|