Forum Discussion

veronica_glynn's avatar
veronica_glynn
Contributor
10 years ago

Retrieving data from WebService XML via XPath

Hi! I am generating data via our web services and need to retrieve data to pass into another web service call but I am having difficulties accessing that data. I have tried using a 'Find', 'FindAll', 'FindAllChildren', FindChildByXPath, and Find with XPath. So far, none of these methods have run successfully. I receive an 'Object doesn't support this property or method' error. I am trying to run the 'Find' directly against the XML. I am also having issues obtaining a particular Node. Regardless of the Node I request, it always returns the root Node. Snippet of code is entered below... 



Thanks for any help! I am stuck..




 


 



Call WebServices.CogneroContentImportService. GetUsersQuestionSetTree(userID)



XML.GetUsersQuestionSetTree.Check WebServices.CogneroContentImportService 



    


Set Doc = Sys.OleObject("Msxml2.DOMDocument.6.0")


 


Doc.async = False


  


    ' Load data from a file


 Call Doc.load("D:\\XML\GetUsersQuestionSetTree\GetUsersQuestionSetTree.xml")


  


Set Nodes = Doc.selectNodes("//Soap/GetUsersQuestionSetTreeResponse")


    


    'set your xpath variable


xpath1 = ".//add[@nodeTypedValue = 'LogsDirectory']"


    'execute the FindChildByXPath method and assign the object to LogsDirectory

NOTE: THIS IS WHERE IS FAILS - OBJECT NOT SUPPORTED


Set LogsDirectory = Doc.FindChildByXPath(xpath1, False)


    'now that you have the node object get the value of the 'value' attribute


sLogsDirectoryValue = LogsDirectory.GetAttribute("value", QuestionSetmetaScripts)


        Log.Message ("Result: " + sLogsDirectoryValue)

1 Reply

  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Veronica, you are attempting to use methods for a Test Complete object against an IXMLDOMDocument

     


    The following line in your example returns an instance of IXMLDOMDocument:


     


    Set Doc = Sys.OleObject("Msxml2.DOMDocument.6.0")


     


    You then attempt the following, which fails as the Method FindChildByXPath does not exist on IXMLDOMDocument


     


    Doc.FindChildByXPath(xpath1, False)


     


    You will need to use the IXMLDOMDocument Methods as defined in the IXMLDOMDocument/DOMDocument Members documentation.




    Regards,


    Phil Baird