Forum Discussion

Nordic's avatar
14 years ago

access child node in parsed tree (xml parse)

Hi,

i am trying to access a child node within an parsed xml tree(blob data from oracle) in an groovy test step.

First i get a blob out from my database and parse this blob, afterwards i select the needed nodes from this stream and save them into properties test step.

The parsed Blob string now looks like:

[ORDER[attributes={}; value=[EXEC_DATE[attributes={}; value=[2012-02-27 00:00]], TNUMBER[attributes={}; value=[1754783]], ABZ[attributes={}; value=[ST-V15]], KZ[attributes={}; value=[01]], AB[attributes={}; value=[6]], CITY[attributes={}; value=[LONDON]], PRODUCT_CODE[attributes={}; value=[CL_23]], SL[attributes={}; value=[SL_NAME[attributes={}; value=[SL-269]], SL_MANUFACTURER[attributes={}; value=[HU]], SL_TYPE[attributes={}; value=[TM]], SL_PORTS[attributes={}; value=[SL_PORT[attributes={}; value=[014-06]]]]]]]]]



Nodes that do not have any childs are working with below groovy code, e.g for the ID("TNUMBER") but not for the NAME("SL_NAME"):


{
blob = (oracle.sql.BLOB)it.original;

byte_stream = blob.getBinaryStream();
if( byte_stream == null )
{
log.info "Test: Received null stream!"
}
else
{
def node = new groovy.util.XmlParser(false,false).parse(byte_stream);
def blobid = node.get("TNUMBER").text();
propertyStep.setPropertyValue("ID", blobid);


def blobname = node.get("SL_NAME").text();
propertyStep.setPropertyValue("NAME", blobname);
log.info "successful parse: " + blobid + blobname;

}
}


My Problem is that i am not able to get the value of the child node "SL_NAME", in this example "SL-269" with my groovy code above.

It would be great if someone who's more experienced in groovy and soapui could help me access nodes with childs.
No RepliesBe the first to reply