| || |
UFT 11.5 - Change File Extension by QTP [ From .csv to .xml]
HI Folks, here is my prob, my scenario is i need to export some details from my window application. While exportiong the file, the file extension would be .csv format, i need to change the file format into .XML
is it possible to do this via UFT\QTP ? kindly suggest me if you have any tips or tricks which would be hlpful for me
Thanks in Advance
Have you tried by providing "test.xml" in "save as" window, Even if you save the file, i don't think you will be able to use that .xml. On "save as" provide the file using "SendKeys" method.
After you done exporting, you can try renaming by below piece of code.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "e:\Text.csv" , "e:\Text.xml"
Do you really just want to rename the file extension? If so the above code will do it.
But that really doesn't have anything to do with turning a csv format file into a properly formatted xml file.
I assuem you're doing file format conversion, surely you can wrtie VBScript to do it, you can use "Scripting.FileSystemObject" to read the CSV file then use "MSXML2.DomDocument" to write the XML file.
One option for you is to let Excel do the conversion, if you have it installed. Create an excel object, load the .csv file, then save it as an XML worksheet. That will at least convert it to valid xml but it will be in the format that Excel reads.
If you're looking for a specific XML format then you'll have to write some code to do that transformation. I'd recommend creating an xml object (either using the DOM or XMLUtil) then looping through your csv file, adding XML elements to the object for each field. Finally, save the xml object to a file.