XPath syntax - ways to get/test XPath

LegacyForumLegacyForum Posts: 1,669 ✭✭
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

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    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
    w3schools XPath Tutorial
    w3schools XPath Syntax

    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>

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

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

Sign In or Register to comment.