|
有点晚了~随便写写睡觉去了~没写啥注释自己研究去吧,我对xml也不老熟悉的-.-!
Dim xmlDoc,Head
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.load "D:\QTP\Test.xml"
Set Root = xmlDoc.documentElement
Set Childs = Root.childNodes
Set Head = Childs.item(0)
Set Body = Childs.item(1)
Set varID = Head.childNodes.item(0)
Set varFrom = Head.childNodes.item(1)
Set varTo = Head.childNodes.item(2)
Set varCc = Head.childNodes.item(3)
i = 1
For Each BodyChild In Body.childNodes
Set varName = BodyChild.childNodes.item(0)
Set varNo = BodyChild.childNodes.item(1)
DataTable.SetCurrentRow(i)
DataTable.Value(1, dtGloabalSheet) = varID.firstChild.nodeValue
DataTable.Value(2, dtGloabalSheet) = varFrom.firstChild.nodeValue
DataTable.Value(3, dtGloabalSheet) = varTo.firstChild.nodeValue
DataTable.Value(4, dtGloabalSheet) = varCc.firstChild.nodeValue
DataTable.Value(5, dtGloabalSheet) = varName.firstChild.nodeValue
DataTable.Value(6, dtGloabalSheet) = varNo.firstChild.nodeValue
i = i + 1
Next
DataTable.Export ("D:\QTP\Test.xls") |
|