You are on page 1of 2

'======================XML_FILE_IMPORT========================================

XMLDataFile = "C:\Documents and Settings\PcUser\Desktop\ROBINNNNN\simple.xml"


Set xmlDoc = CreateObject("Microsoft.XMLDOM")
'xmlDoc.Async = False
msgbox xmlDoc.Load(XMLDataFile)
' update the nodes to avoid duplicate file and validate scenarios
'Error1=xmlDoc.getElementsByTagName("Error_worning_No").item(0).Text
''Error1=xmlDoc.getElementsByTagName("Error_worning_No").item(0).Texta
'msgbox Error1

Set nodes1 = xmlDoc.SelectNodes("/fileInformation/Error_worning_No")


Set nodes2 = xmlDoc.SelectNodes("/fileInformation/Error_worning_Message")
a=nodes1.Length
b=nodes2.Length
For i=0 to a-1
Error1=xmlDoc.getElementsByTagName("Error_worning_No").item(i).Text
msgbox Error1
Set oexcel = CreateObject("Excel.Application")
'====from xml file to excel sheet/ You have to create a excel file on this locat
ion===========
Set obook = oexcel.Workbooks.Open("C:\Documents and Settings\PcUser\Desktop\ROBI
NNNNN\xml.xls")
' Writing values into excel sheet
oexcel.Cells(i+2,1) =Error1a
obook.Save
obook.Close
Next

For j=0 to b-1


massage=xmlDoc.getElementsByTagName("Error_worning_Message").item(j).Text
msgbox massage
Set oexcel = CreateObject("Excel.Application")
Set obook = oexcel.Workbooks.Open("C:\Documents and Settings\PcUser\Desktop\ROBI
NNNNN\xml.xls")
' Writing values into excel sheet
oexcel.Cells(j+2,2) =massage
obook.Save
obook.Close
Next
'===============================MAIN CODE=======================================
==================
Datatable.AddSheet "xml_Data"
Datatable.ImportSheet "C:\Documents and Settings\PcUser\Desktop\ROBINNNNN\xml.xl
s","Sheet1","xml_Data"
row=Datatable.GetSheet("xml_Data").GetRowCount
Datatable.AddSheet "Real_Data"
Datatable.ImportSheet "C:\Documents and Settings\PcUser\Desktop\ROBINNNNN\RR1.xl
s","Sheet1","Real_Data"
row1=Datatable.GetSheet("Real_Data").GetRowCount
For i=1 to row
Datatable.GetSheet("xml_Data").SetCurrentRow(i)
environment("warning")=Datatable.Value("Error_worning_No","xml_Data")
environment("massage")=Datatable.Value("Error_worning_Message","xml_Data
")
For j=1 to row1
Datatable.GetSheet("Real_Data").SetCurrentRow(j)
environment("real_warning")=Datatable.Value("Error_worni
ng_No","Real_Data")
environment("real_massage")=Datatable.Value("Expected_Re
sult","Real_Data")
If environment("warning")=environment("real_warn
ing") and environment("massage") = environment("real_massage") Then
Set oexcel = CreateObject("Excel.Applica
tion")
Set obook = oexcel.Workbooks.Open("C:\Do
cuments and Settings\PcUser\Desktop\ROBINNNNN\R1.xls")
' Writing values into excel sheet
oexcel.Cells(j+1,3) =environment
("massage")
oexcel.Cells(j+1,4) ="PASS"
obook.Save
obook.Close
Exit For
Else
Set oexcel = CreateObject("Excel.Applica
tion")
Set obook = oexcel.Workbooks.Open("C:\Do
cuments and Settings\PcUser\Desktop\ROBINNNNN\R1.xls")
' Writing values into excel sheet
oexcel.Cells(i+1,3) =environment("massag
e")
oexcel.Cells(i+1,4) ="FAIL"
obook.Save
obook.Close
End If
Next
Next

You might also like