Question

I have got a soap response from a webservice where it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<Body>
  <multiref id="1">
    <cpuclock>2300</cpuclock>
    <memoryComponent>
      <item href="#2"/>
      <item href="#3"/>
    </memoryComponent>
  </multiref>
  <multiref id="2" type="ns2:MemoryComponent">
    <type>RAM</type>
    <quantity>2048</quantity>
  </multiref>
  <multiref id="3" type="ns3:MemoryComponent">
    <type>RAM</type>
    <quantity>1024</quantity>
  </multiref>
</Body>

What I am trying to achieve is to recover the memoryComponent elements. Since I am using the XMLUtil of VBScript/QTP, I've been trying to workaround using XPATH (by predicates). Ends-with is not supported by my QTP framework version. Any suggestions?

TIA!

Was it helpful?

Solution

I've found a way to retrieve the elements I wanted.

Set childElements = XMLFile.ChildElementsByPath("/Body/multiref[contains(@type,'MemoryComponent')]")

This workaround suits my needs pretty well. Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top