Forum Discussion

teemu_selkala's avatar
teemu_selkala
Occasional Contributor
12 years ago

Filtering tag-values from an xml file

Sorry if this is too close to this thread: http://smartbear.com/forums/f74/t76212/Search-for-a-string-in-excel-workbook



Anyways. I have a scenario where I test databases by inputting a changing xml file to database and want to verify that values were inputted correctly. It might be that I search with wrong keyword but trying to find something with keyword "filter" brought up something very different I was looking :).



So I have e.g.



<tag_name = "Tag_value"> inside a file and I would like to filter out Tag_value in order to compare it to database values but I didn't at least yet find any convinient way to handle this - so any help is apprichiated - link to corrent help file, examples, etc.



Thank you and best seasonal greetings to all :)

5 Replies

  • teemu_selkala's avatar
    teemu_selkala
    Occasional Contributor


    Hi,



    First of all, happy new year to all those who already celebrated it :). Related to above question my goal initially was that I would filter our from xml log created whether on console window output-stream there is a name of a specific file when I check what all is contained in specific folder.



    After that I read stdOut method that I could use for storing stream from console window and I was wondering would there be easier way to handle what I want (=checking whether a specific file name is within a specific folder).



    so if I store input from console to something like...



    Recset = commandwindow.stdOut

    Recset.MoveFirst();

    while (Recset ! EOF)

    {

     if(Recset.Value == "File_I_Want_to_check")

     {

      Do_actions_I_want_to_do

     }

     Recset.MoveNext()

    }



    so would something like this do the trick? Just kind of wondering could I do things easier than currently

     



    Thank you for your help =)
  • teemu_selkala's avatar
    teemu_selkala
    Occasional Contributor
    ups, sorry, misclick posted too early, so getting output with following code:




    function CheckIfThereIsXMLinInputFolder()



    {



    // Launch console



    var shell = Sys.OleObject("WScript.Shell");



    var exec = shell.Exec("console I use for testing");



    // Input text to winscp.com window



    exec.StdIn.Write(



    "open session\n" +



    "cd folder I check the xml file existense on server\n" +



    "ls\n" +



    "exit\n");



    // we store all output from the winscp.com window



    var output = exec.StdOut.ReadAll();



    // we store up status from going through output and searching from it if there



    // is an file with .xml ending there



    var result = aqString.Find(output,".xml")



    // if we find a file with .xml ending we do this



    if(result != -1)



    Log.Message("Found an file with .xml ending, therefore need to run xyz again")



    // and if we don't we can happily proceed with copying files...



    else



    Log.Message("Didn't find any xml ending files")



    }