51Testing软件测试论坛

标题: 修改xml中的值 [打印本页]

作者: superliming    时间: 2010-11-18 16:52
标题: 修改xml中的值
<alarmlist>
        <NT_ALARM>
                <property name="notificationId">
                        <org.jacorb.orb.Any>
                                <value>2</value>
                        </org.jacorb.orb.Any>
                </property>
              </NT_ALARM>
</alarmlist>
修改<value>2</value>
把2修改成5,如何修改。用vbs
Set xmlDoc = CreateObject("Microsoft.XMLDOM") ' 创建XMLDOM对象
xmlDoc.async = False   
xmlDoc.load "D:\NT_ALARM.xml"
If xmlDoc.parseError.errorCode <> 0 Then   
   Set myErr = xmlDoc.parseError
   MsgBox("XML Loads Failed. " & myErr.reason)
Else
         Set rootNode = xmlDoc.documentElement
               rootNode.childNodes(0).childNodes(11).attributes(0).nodeValue 这里如何写?
                 xmlDoc.save "D:\NT_ALARM.xml"
End If
Set xmlDoc = Nothing
作者: xhhuang1618    时间: 2010-11-18 17:52
Set xmlDoc = CreateObject("Microsoft.XMLDOM") ' 创建XMLDOM对象
xmlDoc.async = False   
xmlDoc.load "D:\NT_ALARM.xml"

If xmlDoc.parseError.errorCode <> 0 Then   
   Set myErr = xmlDoc.parseError
   MsgBox("XML Loads Failed. " & myErr.reason)
Else
        xmlDoc.getElementsByTagName("NT_ALARM")(0).childNodes(0).childNodes(0).childNodes(0).text = 8
     xmlDoc.save "D:\NT_ALARM.xml"
End If
Set xmlDoc = Nothing
作者: superliming    时间: 2010-11-19 13:23
谢谢
作者: xieyang702    时间: 2010-11-19 16:50
2楼很强




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2