Forum Discussion

sguda's avatar
sguda
Regular Contributor
13 years ago

Can we retrieve the XML file values through TC8.5

Hi,



I am using TC 8.5. After accessing the database record, one of the fields for the record has the link for xml file. My goal is I have to access that filed value which is xml file link and open the file open that xml file automatically(with automation) and verify the xml field values.

I am attaching the snap shots of how databaase record looks like and how the data is in xml file.



So please let me know if this is possible. If possible where to go and look for the solution.

7 Replies

  • sguda's avatar
    sguda
    Regular Contributor
    Hi,



    Where do I have to go to see sample code from  Test Complete Samples ex: <TestComplete Samples>\Miscellaneous\Storages

    It is leading to help file but again i tsee these links and i don't know where to go for the code.



    Please elt me know.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    in your AllUsers folder for documents there should be a TestComplete 8 Samples folder.
  • sguda's avatar
    sguda
    Regular Contributor
    Hi,



    There is function to pass the pareameter of xml file  and convert xml field values into table.

    This is th code in the sql we are using.



    DECLARE @xml1 XML


    SELECT @xml1 = (SELECT dataitems FROM dbo.Form_StudentData WHERE IDForm_StudentData=654588)


    select @xml1


    SELECT * FROM dbo.udf_GetTableFromDataItems(@xml1)


    select FieldValue from dbo.udf_GetTableFromDataItems(@xml1) where IDForm_FieldDefinition = '11952'



    How can i make this work in Test Complete to retrieve the xml file values. I wnat to retrieve FieldValue FROM THE TABLE GENERATED BY FUNCTION for a particular IDForm_FieldDefinition.



    I am attcahing the snap shots of the table generated.

  • sguda's avatar
    sguda
    Regular Contributor
    Hi, 



    I tried to retrieve XML file link and calling existing function in the database which converts xml file to table and reads fieldvalue for specific form id  through Test Complete.

    This script is not giving error but not retrieving xml file or data that is created in the table due to conversion.

     


    Sub Extract_XML



    Dim xmlFile



    Set aCon1 =



     



     



    ADO.CreateADOConnectionaCon1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Eligibility"



    aCon1.LoginPrompt = False

    aCon1.Open 



    xmlFile =
    storages.XML("")



    set Recset2 = aCon1.Execute_("SELECT dataitems FROM dbo.Form_StudentData WHERE (IDForm_StudentData = 654588)")



    xmlFile = Recset2.Fields("dataitems").Value


    Log.message xmlFile



    Set Recset1 = aCon1.Execute_("select FieldValue from dbo.udf_GetTableFromDataItems('" & xmlFile & "') where (IDForm_FieldDefinition = 11952)")

    Log.Message Recset1.Fields("FieldValue").Value



    end sub

     




  • Hi Sri,





    It's possible that I miss something, but it looks more like an SQL question. Could you please clarify how the behavior you observe is related to TestComplete and what is the difference between the expected and the actual behavior of the tool? Also, give us a detailed, step-by-step description of the actions your test needs to perform. I'm not sure I understand your scenario completely.