Forum Discussion

Arcano_Sombrio's avatar
Arcano_Sombrio
New Contributor
9 years ago
Solved

How to get node value of XML using function getElementsByTagName on VBScript?

I'm utilizing version 11.0.644 of TestComplete. XML: <tag1>      <tag2>          <mod>Test </mod>      </tag2> </tag1> I'm using this code for obtain the node value from XML: Sub XMLTes...
  • ghuff2's avatar
    ghuff2
    9 years ago

    Okay, this line of your code:

     

    XMLTestReader.load(XML.XML_Teste.Document)

     

    The load method of MSXML takes a filepath to an XML file as the argument. XML.XML_Teste.Document will return a DOM object that represents the XML, not the filepath. If you want you can pass in the actual file path to the XML file, but Document property of an XML checkpoint already return a DOM object like what you want. So your code could just be like this:

     

    Sub XMLTest
    Set nodeText = XML.XML_Teste.Document.getElementsByTagName("mod").item(0).text
    BuiltIn.ShowMessage(nodeText)

    I use python so hopefully that's all the correct syntax.