Forum Discussion
So, here is part of my request and response in the CData format ...
I would like the response to be displayed in the xml format.
If not possible, is there an easy way to write assertions for the data returning in the CData format?
I couldn't find anything except 'Contains' assertion. I would like to use XPath.
Request:
<soapenv:Body>
<web:CalculateQuote>
<!--Optional:-->
<web:QuoteXML><![CDATA[<QuoteObject>
<Insured>
<Quote>
<EffectiveDate>08/10/2011</EffectiveDate>
<OriginalEffectiveDate>08/10/2011</OriginalEffectiveDate>
Response:
<CalculateQuoteResult><![CDATA[<QuoteObject><Insured UnitNumber=""><Quote UnitNumber=""><EffectiveDate>08/10/2011</EffectiveDate>
Thanks.
http://stackoverflow.com/questions/19745210/what-xpath-to-select-cdata-content-when-some-childs-exist
So first extract value that is in cdata, then use xmlslurper to parse that data and apply xpath on it.
- sharmameera9 years agoContributor
Thanks! I will try that out.
- sharmameera9 years agoContributor
Thanks for the information Rao.
The script was really simple, and works fine!
def rootNode = new XmlSlurper().parseText('My CData Text')
assert rootNode.name() == 'The Root node in my CData'
assert rootNode.State.text() == AZ (State being one of the nodes in the CData).
Thanks!
Related Content
- 6 months agomacheshmeh