Forum Discussion

gynaecoid's avatar
gynaecoid
New Contributor
16 years ago

How to verify data inside <![CDATA[ ... ]]>

Hello all!
My question is how can I verify block of data inside ... section by means of XpathMatch or Contains or any other assertion.

For example if I have SOAP response which contains:


   
      <?xml version="1.0" encoding="UTF-8"?><br />...<br />&nbsp; &nbsp; &nbsp; &nbsp; <dbExtentions><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <propertyTable><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <propertyName>ExternalTradeId</propertyName><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <propertyValue>TLT008901</propertyValue><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </property><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </propertyTable><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <trader><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <partyId>BAN_EMCRD</partyId><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <userId>SURAGO</userId><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <userName>GOP</userName><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </trader><br />...<br />...<br />&nbsp; &nbsp; &nbsp; &nbsp; </dbExtentions><br />&nbsp; &nbsp; </body><br /></TPML>
   


I am able to verify a single tag value by simple RegExp:
(?s).*body.*dbExtentions.*propertyTable.*property.*ExternalTradeId.*TLT008901.*

But what should be done if I need to verify the whole 
sections.

Many thx in advance!

6 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    What if you set the XPath to select the element containing this CDATA, then the expected value should be the desired XML where you can use the wildcard feature to "mask away" those element you don't want to check!?

    regards,

    /Ole
    eviware.com
  • gynaecoid's avatar
    gynaecoid
    New Contributor
    Hello Ole!
    Many thanks for your reply.
    contains('...') worked fine for me however I should mention that wild cards functionality does not work inside CDATA section e.g.

    contains('*...') does not pass


                   
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    ok.. but what if you set the xpath to select the returnValue element? The expected content should then be the cdata text, in this case the wildcards should work ok.. or am I wrong?

    regards!

    /Ole
    eviware.com
  • gynaecoid's avatar
    gynaecoid
    New Contributor
    Hi Ole,
    Thank you for prompt response.
    I've set the Xpath expr as follows:
    /SOAP-ENV:Envelope/SOAP-ENV:Body/ns:tpmlMessageString

    This is the content I receive:

    <?xml version="1.0" encoding="UTF-8"?><br /><ns0:TPML xmlns:ns0="urn:x-schemas-db-com:tpmbase/tpml/tpml_1_2"><ns1:tpHeader xmlns:ns1="urn:x-schemas-db-com:tpmbase/tpml/tpheader_1_2"><ns1:messageTimestamp>2008-12-17T13:33:25.839Z</ns1:messageTimestamp>...<br /><br />So in case I change messageTimestamp value to '*' matcher constantly fail. So is there any posibility to apply wildcards for Xpath matcher
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    what if you set the xpath to

    /SOAP-ENV:Envelope/SOAP-ENV:Body/ns:tpmlMessageString/text()

    ?

    regards,

    /Ole
    eviware.com
  • gynaecoid's avatar
    gynaecoid
    New Contributor
    Hi,
    I've tried this one as well but still did not succeed although wildcards works with no problems in any other case.
    So apparently wildcards doesn't work with * inside the CData tag