第1个回答 推荐于2017-11-27
Private Sub Command1_Click()
Dim xDoc As Object
Dim xmlFile As String
Dim strWidth As String
Dim strHeight As String
Set xDoc = CreateObject("MSXML2.DOMDocument")
xmlFile = "C:\aa.xml"
xDoc.Load xmlFile
strWidth = xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes(2).Text
strHeight = xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes(3).Text
MsgBox ("Width=" & strWidth & " Height=" & strHeight)
xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes(2).Text = "123"
xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes(3).Text = "456"
xDoc.save (xmlFile)
End Sub
注意 你上面的XML中Width="840"Height="630" 要分开,改成:
Width="840" Height="630"本回答被提问者采纳