Forum Discussion
jtheuer
16 years agoOccasional Contributor
Thanks, that code works:
Now, I wanted to port the code to retrieve a list of values (ids) and then perform a testrun on each of them for this xml:
As you can see, I even didn't get to the id retrieval part, the problem is that I get: "java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 7 in {//ns1:e/id}: Prefix ns1 has not been declared" Although I just copied the code from the working request above.
Can you tell me how I can retrieve a list of elements?
Cheers,
Jan
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
// create holder for last response and log requestId
def holder = groovyUtils.getXmlHolder( "upload simple tour#ResponseAsXml" );
def p_url = holder.getNodeValue( "//ns1:url" );
log.info("url value: " + p_url );
// assign single property
testRunner.testCase.setPropertyValue( "uploadID", p_url);
Now, I wanted to port the code to retrieve a list of values (ids) and then perform a testrun on each of them for this xml:
<Response>
<e>
<id>416</id>
<name>Hans</name>
</e>
<e>
<id>417</id>
<name>John</name>
</e>
</Response>
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder( "getAllTours#ResponseAsXml" );
def items = holder.getNodeValue( "//ns1:e/id" );
for(def item: items) {
log.info("id: " + item );
}
As you can see, I even didn't get to the id retrieval part, the problem is that I get: "java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 7 in {//ns1:e/id}: Prefix ns1 has not been declared" Although I just copied the code from the working request above.
Can you tell me how I can retrieve a list of elements?
Cheers,
Jan