Forum Discussion

Jacob_Hassing's avatar
Jacob_Hassing
Contributor
16 years ago

Assertion question

hi
is it possible in an xpath assertion to validate that at least 1 of the returned element will have a specific value.

Consider this part of xml response:

          [sub:2pc0bcl4] 
               230
               ACT
               549251812
               Reference A
           

           
               231
               ACT
               5492518332
               Reference B
           
[/sub:2pc0bcl4]


there might be many agreement elements, but i want to verify that at least 1 of the reference elements has the value = "Reference B"

6 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    maybe you could do something like

    declare namespace ns=..
    count( //ns:Reference[text()='Reference B'] ) > 0

    ?

    /Ole
    eviware.com
  • just tried this suggested.
    looked like this
    [sub:kwsoh44f]count( //ns2:FindAgreementsResponse/agreement/ns1:Reference/text()='Reference B' )[/sub:kwsoh44f]

    count does always return 1 though, no matter what text i put in.
    So i guees this will not work for me ?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    can you please show or attach the entire message so I can get this right?

    regards!

    /Ole
    eviware.com
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    Please try changing the last line to

    count( //ns2:FindIdentitiesResponse/Identities/ns1:IdentityHandle[text()='1222'] )

    regards!

    /Ole
    eviware.com