Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write the xpath for the attributes present in the xml tag using GROOVY script in SOAP UI

 
Haricharan Gadamchetty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a CDATA xml. I was able to parse the XML till CDATA. But, I am unable to write the XPATH for the attributes present in the Node. Please find the sample below.

NodeName=Item, attribute=ItemID
<Item ItemID="XXX-XXXX">


Groovy Script:

import com.eviware.soapui.support.XmlHolder
respXmlHolder = new XmlHolder(messageExchange.getResponseContentAsXml())
respXmlHolder.declareNamespace("ns1","http://example.com/types")
CDATAXml = respXmlHolder.getNodeValue("//ns1:Response[1]/result[1]")
log.info(CDATAXml)
CDATAXmlHolder = new XmlHolder(CDATAXml)
Item = CDATAXmlHolder.getNodeValue("//ItemID")
log.info("Item = $Item")
assert '397-0109'== Item.@ItemID.text()


Can someone please help me in getting the value of ItemID attribute using groovy script in SOAPUI.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!