木子屋 Dnawo's BLOG

VB6.0读取XML示例

👤 dnawo 📅 2009-09-28 👁 10307 👍 0 💬 0 🔄 来源:本站原创
Option Explicit


Private Sub Form_Load()
    '需引用 Microsoft XML, v6.0
    Dim xmlDoc As DOMDocument
    Dim nodeList As IXMLDOMNodeList
    Dim node As IXMLDOMNode
    
    On Error Resume Next
    
    Set xmlDoc = New DOMDocument
    xmlDoc.loadXML ("<xml><website><domain>mzwu.com</domain><webmaster>dnawo</webmaster></website><website><domain>abc.com</domain><webmaster>abc</webmaster></website><website><domain>def.com</domain><webmaster>def</webmaster></website></xml>")
    Set nodeList = xmlDoc.selectNodes("//website")
    For Each node In nodeList
        Text1.Text = Text1.Text & node.selectSingleNode("domain").Text & vbCrLf
    Next
        
    If Err.Number <> 0 Then
        MsgBox Err.Description
    End If
    
    On Error GoTo 0
End Sub

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 VB6.0编程给DataGrid绑定数据示例 下一篇 → 淘宝网开放平台API(taobao.items.all.get)…