xml文档大概是这样的结构
<Use logindate="10/23/2014">
 <user  用户ID="11"  UserID="113"  userEName="qwe"/>
.......... 
</Use> 
怎么用VB更改userEName的属性值,谢谢

解决方案 »

  1.   

    这个用的不多,参考着改吧:
    Sub ChangeXMLNodeAttribute()
        Dim xmlDoc, xmlNode, xmlFile
        xmlFile = "e:\xml.xml"
        Set xmlDoc = CreateObject("Microsoft.XMLDOM")
        xmlDoc.async = False
        xmlDoc.Load xmlFile
        If xmlDoc.parseError.errorCode <> 0 Then
            MsgBox "打开错误:" & xmlDoc.parseError.reason
            Exit Sub
        End If
        Set xmlNode = xmlDoc.documentElement.getElementsByTagname("user")
        If xmlNode.length = 1 Then
            If xmlNode(0).Attributes(2).Name = "userEName" Then
                xmlNode(0).Attributes(2).Value = CStr(Timer) ''随机值
                xmlDoc.save xmlFile ''更新到文件
            End If
        Else
            MsgBox "有0或者多个节点....."
        End If
        Set xmlDoc = Nothing
        Set xmlNode = Nothing
    End Sub
      

  2.   

    vb 操作xml