Hi I am new to QTP Automation. Can anyone define a process or code to convert Excel data into xml format using QTP....thanks in advanceSatya

Questions by meattesting   answers by meattesting

Showing Answers 1 - 3 of 3 Answers

You wil have to first create FSO for Excel and then try following script.

Make sure the excel file mentioned is in place


set sh = CreateObject("Scripting.FileSystemObject")
set exl = CreateObject("Excel.Application")
exl.visible = true

set wb = exl.WorkBooks.Open("C:try_excel.xls")
set ws = wb.Worksheets("Sheet1")

ws.Activate

Dim operation

operation = exl.ActiveSheet.Cells(Row,4).Value

msgbox operation

  Was this answer useful?  Yes

Hi

Thanks for the reply..I have completed that stuff in another way.Now i need to compare the XML files.I need to featch Two folders/subfolders and compare the files from those sub folders/folders.I have done for comparsion of XML files but i need to write the result in the XML file.

I have tried out in the following way ...

   Function CompareFolder_Files (FolderName1,FolderName2)
 
    Dim fso1,FirstFolder,f1,fc1,strTXT1,TextFile1 'For First Folder
 
    Dim fso2,SecondFolder,f2,fc2,strTXT2,TextFile2 'For Seconf Folder.
 
    Dim strPath(100 ), strDest(100 )
 
    Set Acutaldoc = XMLUtil.CreateXML()
     
    Set Excepteddoc = XMLUtil.CreateXML()
 
    Set fso1 =CreateObject("Scripting.FileSystemObject")
 
    Set fso2=CreateObject("Scripting.FileSystemObject")
 
    Set FirstFolder=fso1.GetFolder(FolderName1)

      Set FirstFolder_Sub=FirstFolder.SubFolders

                Set SecondFolder=fso2.GetFolder(FolderName2)

      Set SecondFolder_Sub=SecondFolder.SubFolders
 
    Set  fc1=FirstFolder.Files
 
    Set  fc2=SecondFolder.Files
 
    i=1
 
    For Each f1 in fc1
 
         strPath(i)=f1.path

         Acutaldoc.Loadfile strPath(i)
      
         strActualPath=strPath(i)
      
         i=i+1
    Next
 
    i=1
    
    For Each f2 in fc2
 
         strDest(i)=f2.path
     
         Excepteddoc.Loadfile strDest(i)
     
         strExceptedpath= strDest(i)
     
         i=i+1
                Next
 
    i=1 
   
    For i=1 to fc1.count
 
         Set Actualdoc = XMLUtil.CreateXML()
          
         Set Excepteddoc = XMLUtil.CreateXML()
      
         Set Actualdoc1 = XMLUtil.CreateXML()
          
         Set Excepteddoc1 = XMLUtil.CreateXML()
      
         Actualdoc1.Loadfile strPath(i)
 
         Excepteddoc1.Loadfile strDest(i)
 
         Msgbox Actualdoc1
      
         Msgbox Excepteddoc1
         
          Actualdoc.Load Actualdoc1.ToString

         ' Actualdoc.GetRootElement.ChildElements.Item(1).Namespace=True
      
          Excepteddoc.Load Excepteddoc1.ToString

         'Excepteddoc.GetRootElement.ChildElements.Item(1).Namespace=True

                                   
          XMLres = Actualdoc.Compare (Excepteddoc,resultXML,micXMLNone+micXMLAttributes+micXMLCDataSections+micXMLValues)

         msgbox resultXML' (Error Namespace cannot be false)
         
                                   Set result = XMLUtil.CreateXML()

                                    result.Load  resultXML.ToString

                                    result.SaveFile"C:XMLResultResult.xml"

                                    If XMLres = 1 then
      
           msgbox "Documents match"
      
         Else
      
           msgbox "Do not match :-("
      
         End If
    
      Next
    
  
  End Function

Can Help me .....

I m stuck with the NameSpaces error...wating for u r reply ...

  Was this answer useful?  Yes

Hi........
i to want to convert the data from XL to xml or html with the help of QTP......
i think you did a similar stuf..........
can u plz help me out....
Looking forward for your positive response...
Regards dipti

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions