import com.eviware.soapui.support.*
def soapmessage = '''<ns:basket xmlns:ns="http://example.com">
<ns:fruit>
<ns:name>banana</ns:name>
<ns:color>yellow</ns:color>
</ns:fruit>
<ns:fruit>
<ns:name>apple</ns:name>
<ns:color>green</ns:color>
</ns:fruit>
<ns:fruit>
<ns:name>strawberry</ns:name>
<ns:color>red</ns:color>
</ns:fruit>
</ns:basket>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = new com.eviware.soapui.support.XmlHolder( soapmessage )
//holder.namespaces["ns"] = "http://example.com"
//holder.declareNamespace("ns", "http://example.com")
assert holder.getNodeValue("//ns:fruit[2]/ns:color[1]") == "green"
holder.removeDomNodes("//*:fruit[2]")
assert holder.getNodeValue("//ns:fruit[2]/ns:color[1]") == "red"
log.info "Done"
def soapmessage = '''<ns:basket xmlns:ns="http://example.com">
<ns:fruit>
<ns:name>banana</ns:name>
<ns:color>yellow</ns:color>
</ns:fruit>
<ns:fruit>
<ns:name>apple</ns:name>
<ns:color>green</ns:color>
</ns:fruit>
<ns:fruit>
<ns:name>strawberry</ns:name>
<ns:color>red</ns:color>
</ns:fruit>
</ns:basket>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = new com.eviware.soapui.support.XmlHolder( soapmessage )
//holder.namespaces["ns"] = "http://example.com"
//holder.declareNamespace("ns", "http://example.com")
assert holder.getNodeValue("//ns:fruit[2]/ns:color[1]") == "green"
holder.removeDomNodes("//*:fruit[2]")
assert holder.getNodeValue("//ns:fruit[2]/ns:color[1]") == "red"
log.info "Done"
No comments:
Post a Comment