vb下读xml
作者:admin 日期:2008-04-03
引用microsoft xml version2.0 控件
Option Explicit
Dim xml As DOMDocument
Private Sub cmdLoad_Click()
Set xml = New DOMDocument
Call xml.Load(App.Path & "\xmlTest.xml")
Dim root As IXMLDOMElement
Set root = xml.documentElement
Dim node As IXMLDOMNode
For Each node In root.childNodes
Debug.Print node.nodeName & ":" & node.Text
Next
End Sub
Private Sub Form_Load()
Call cmdLoad_Click
End Sub
XML如下:
<?xml version="1.0" encoding="gb2312"?>
<test>
<type name="古典武侠">侠义天下</type>
<book name="寻秦记" author="黄易" price="25">
<chapter2 title="科学疯子" page="87">被拉过去当实验品</chapter2>
<chapter3 title="阴错阳差" page="44">实验失败,来到了三年前秦国</chapter3>
<chapter4 title="美蚕娘" page="26">在荒野山村遇到美蚕娘</chapter4>
</book>
</test>
Option Explicit
Dim xml As DOMDocument
Private Sub cmdLoad_Click()
Set xml = New DOMDocument
Call xml.Load(App.Path & "\xmlTest.xml")
Dim root As IXMLDOMElement
Set root = xml.documentElement
Dim node As IXMLDOMNode
For Each node In root.childNodes
Debug.Print node.nodeName & ":" & node.Text
Next
End Sub
Private Sub Form_Load()
Call cmdLoad_Click
End Sub
XML如下:
<?xml version="1.0" encoding="gb2312"?>
<test>
<type name="古典武侠">侠义天下</type>
<book name="寻秦记" author="黄易" price="25">
<chapter2 title="科学疯子" page="87">被拉过去当实验品</chapter2>
<chapter3 title="阴错阳差" page="44">实验失败,来到了三年前秦国</chapter3>
<chapter4 title="美蚕娘" page="26">在荒野山村遇到美蚕娘</chapter4>
</book>
</test>
评论: 0 | 引用: 0 | 查看次数: 1448
发表评论
你没有权限发表留言!