Forum Discussion

duskolokin's avatar
13 years ago

XPathMatch Assertion for a node not occurring more than once

Im looking for a way to make an XPathMatch Assertion to ensure that a node doesn't occur twice in my XML Response.

This is what I've done so far:

declare namespace x="http://schschsch.dadadadada.org/Tctc.Prprprprpr.Sesesese.Prprprprpr.v1"
//a:PriceComponents/a:PriceComponent[a:PriceComponentCode = 'GRR']

In the Expected result box I get the following answer:

<a:PriceComponent xmlns:x="http://schschsch.dadadadada.org/Tctc.Prprprprpr.Sesesese.Prprprprpr.v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<a:Amount>100</a:Amount>
<a:PaxNo>1</a:PaxNo>
<a:PriceComponentCode>GRR</a:PriceComponentCode>
</a:PriceComponent>

But can I in any way make the expected result be, for example a number, lets say that I set the number 2, then the assertion will only be ok if the number of the pricecomponent named GRR occurs at most twice?

Sorry, Im a newbie at this, I'll be happy for any help at all
Cheers

2 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    declare namespace x="http://schschsch.dadadadada.org/Tctc.Prprprprpr.Sesesese.Prprprprpr.v1"
    count(//a:PriceComponents/a:PriceComponent[a:PriceComponentCode = 'GRR'])

    Then put 2 in the Expected Response field.