Forum Discussion

dtoceva's avatar
dtoceva
New Contributor
12 years ago

SOAPUI Xpath Namespace issue

With Soap Ui Pro I need to perform web services testing:
I am sending request and from the received response I need to select proper value which is corresponding on several conditions. I am trying to take that value using Property Transfer and XPath.
My response is as follows:

<Response xmlns="http://xxxxx/xxx/xxx/Get">
<Log/>
<Messages/>
<Offers>
<e>
<Currencies>
<e>
<PayoutAmount>xxx</DevicePayoutAmount>
<DisplayName>xxxx</DisplayName>
<Id>xxxx</Id>
<IsDefault>xxxx</IsDefault>
</e>
</Currencies>
<DisplayName>DressUpPrincess</DisplayName>
<Id>5555</Id>
<ConversionType>1</ConversionType>
</e>

<e>
......(here I am receiving more offers)
</e>
</Offers>

I need to take the Id value 5555 from the offer where the Conversion Type is 1 (or the Display Name is DressUpPrincess).
I am using the following Xpath:
declare namespace ns1='http://xxxxx/xxx/xxx/Get';
//ns1:Response[1]/ns1:Offers[1]/ns1:e[1]/ns1:ConversionType[text()='1']/ns1:Id[1]/text()
but this is returning null.

What I am doing wrong?

Thanks, Diliana
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    you should use groovy script. Here is the similar question just different xml request:

    viewtopic.php?f=2&t=15964

    If you have problems with it just write and I will post here groovy code
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    For one thing you have a mimatched tag

    <PayoutAmount>xxx</DevicePayoutAmount>


    Then the predicate in your xpath is at the wrong level to get the Id. This should work:

    declare namespace ns1='http://xxxxx/xxx/xxx/Get';
    //ns1:Response[1]/ns1:Offers[1]/ns1:e[ns1:ConversionType/text()='1']/ns1:Id[1]/text()
  • dtoceva's avatar
    dtoceva
    New Contributor
    Hi,

    Thank you so much. Yes, it is working now.

    Diliana