Forum Discussion

bdmsavage's avatar
12 years ago

XPath Validation on name/value pairs

Hi all,

I'm pretty new to SOAP UI & XPath and was hoping someone might be able to give me a pointer in the right direction. I have a response that contains a number of name value pairs in this type of format:

<ns2:detailedData>
<ns4:parameterName>name</ns4:parameterName>
<ns4:parameterValue>value</ns4:parameterValue>
</ns2:detailedData>

I want to write a test that is able to check that my response contains an entry with a given parameter name (e.g. name in the example above) and that it has a given value (e.g. value in the example above).

I guess I could so this using a contains match, but this would leave me vulnerable to namespace changes?

Any thoughts greatfully accepted

1 Reply

  • nmrao's avatar
    nmrao
    Community Hero
    It would help you if you learn some xpath basics.

    Name spaces are important, otherwise you will not get the desired result.
    //ns2:detailedData/ns4:parameterValue[../ns4:parameterName='name']/text() will result 'value'

    Any way in this case, tried to give you some example similar to what you have requested for. Hope this will help. Note that I am showing using xpath evaluation tool.