QTP - 如何从xml文档中删除XmlNode?

时间:2011-08-17 06:08:00

标签: vbscript qtp xmldom

我想从xml文档中删除一个xml节点,但我不知道可以使用哪个函数来实现它。你能告诉我怎么做吗?

Const XMLDataFile = "C:\TestData.xml"

xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(XMLDataFile)

nodes = xmlDoc.SelectNodes("/bookstore/book/author[text()='name=admin']")

' get their names
For i = 0 To (nodes.Length - 1)
    Title = nodes(i).NodeValue
    MsgBox("The node will be deleted " & Title)

    'TODO: The expect code here

Next

1 个答案:

答案 0 :(得分:0)

这不是QTP问题,而是一个XML问题。 看MS's documentation我会说以下可能会有效

nodes(i).parentNode.removeChild nodes(i)