上传者: ouyanlyj
|
上传时间: 2023-07-05 20:51:16
|
文件大小: 2KB
|
文件类型: TXT
vb中读写XML文件实例Dim XMLDoc As DOMDocument
Dim root As IXMLDOMNode
Dim xlst As IXMLDOMNodeList, xlst1 As IXMLDOMNodeList
Dim xn As IXMLDOMNode
Dim xnf As IXMLDOMNode
Dim xe As IXMLDOMElement
Set XMLDoc = New DOMDocument
XMLDoc.Load "F:\example\test.xml" 'xml文件路径根据存放路径不同而不同!
Set xn = XMLDoc.selectSingleNode("testlist")
'以下为读取xml文件内容,这里用ListView控件显示
Set xlst = xn.childNodes
ListView1.ListItems.Clear
For Each xnf In xlst
Set xe = xnf
Set xlst1 = xe.childNodes
With ListView1.ListItems.Add(, , xlst1.Item(0).Text)
.SubItems(1) = xlst1.Item(1).Text
.SubItems(2) = xlst1.Item(2).Text
End With
Next