Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

XPath syntax - ways to get/test XPath

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Hello. I have setup some stubs and am mocking up some responses by using the XPath Function matching. However, I can not seem to find much documentation or examples on syntax for this. I can get a basic text="sometext" function to work properly but, I would like to find out how to properly syntax looking for blank text, missing elements, etc. Is there some documentation for this type of thing? I've been unsuccessful searching the web and these forums for what I am needing. Thanks.

Ex. i can get the following to work
/*[local-name(.)="Envelope"]/*[local-name(.)="Body"]/*[local-name(.)="Operation"]/*[local-name(.)="OpHeader"]/*[local-name(.)="Account"]/text()="123"

Ex. Would like to be able to properly syntax and get a correct response for the following but, it errors as seen below
/*[local-name(.)="Envelope"]/*[local-name(.)="Body"]/*[local-name(.)="Operation"]/*[local-name(.)="OpHeader"]/*[local-name(.)="Account"]/text()=""

<Error>
<Reason>None of the XPath Functions succeeded on the incoming message</Reason>
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    edited June 2021
    Options
    Hi,

    If you have access to the request payload, I would recommend you do the following:

    1. Open up SOAtest and create a new empty test suite
    2. Add an XML Data Bank to the test suite
    3. Paste the request payload into the Input section of the XML Data Bank
    4. Run the XML Data Bank

    It will populate the XML Data Bank and you can select the element you want to, click add button followed by modify button. It will build the XPath for you this way. Then you can copy it and paste it into the stub 'XPath Function match' section.

    But for your reference here are some documentation on XPath

    w3 XPath

  • [Deleted User]
    [Deleted User] Posts: 0 admin
    Options

    I like to use either the XML Data Bank or XML Transformer to get initial XPath syntax.