Forum Discussion

kamahade's avatar
kamahade
Regular Contributor
14 years ago

getting childnode in Response

Hi.. I have following code
import com.eviware.soapui.impl.wsdl.teststeps.*;
import com.eviware.soapui.support.XmlHolder;

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def i=0;
def WsdlTestRequestName;

//Get the name of the WSDL test request

for( testStep in testRunner.testCase.getTestStepList() ) {
if( testStep instanceof WsdlTestRequestStep ) {
//log.info i++ +"Name of testcases in this suite: " +"[" +"]" +" Name of the WSDL step is " +testStep.getName();
WsdlTestRequestName=testStep.getName();
}
}
// Get testresponse XML holder object
def responseHolder = groovyUtils.getXmlHolder("${WsdlTestRequestName}#Response");

//Declare the namespace - Hardcoded here. Dont know to get the namespace automatically.
//def names= responseHolder.getNamespaces()
//responseHolder.namespaces["imed"] = "http://blahblahbhala"

//Get all the Nodes of the selected Xpath
node = responseHolder.getDomNodes( "//imed:getMediaAssetResponse/getMediaAssetResponse/mediaAssetInfo/text/*" )

//Traverse each node
node.each {

log.info "map node " + " - " + it.QName.toString() + ":"
}
// Cound number of nodes
def nodeCount = responseHolder.getDomNodes("//imed:getMediaAssetResponse[1]/getMediaAssetResponse[1]/mediaAssetInfo[1]/document[1]/*").length

log.info nodeCount


to Parse following XML
            <copyrightOwner>sonoras imperio</copyrightOwner>
<deletedReason>quae divum incedo</deletedReason>
<approxDuration>100</approxDuration>
<originalRecordedDate>2009-05-16</originalRecordedDate>
<retentionReason>100</retentionReason>
<assetType>100</assetType>
<entityState>100</entityState>
<description>
<em3:Description>fremunt celsa</em3:Description>
<em3:Language>100</em3:Language>
<em3:Type>100</em3:Type>
</description>
<clip>
<id>100</id>
<sourceTimecodeIn>100</sourceTimecodeIn>
<sourceTimecodeOut>100</sourceTimecodeOut>
<sequenceTimecodeIn>100</sequenceTimecodeIn>
<sequenceTimecodeOut>100</sequenceTimecodeOut>
<sourceTimeCodeFormat>
<DropFrameIndicator>true</DropFrameIndicator>
<EditRate>100</EditRate>
<UnknownFormatIndicator>true</UnknownFormatIndicator>
<EditRateType>100</EditRateType>
</sourceTimeCodeFormat>
</clip>


However, I could not get the node names and values of inner XML trees like
   <description>
<em3:Description>fremunt celsa</em3:Description>
<em3:Language>100</em3:Language>
<em3:Type>100</em3:Type>
</description>


any help ?
No RepliesBe the first to reply