Forum Discussion

TesterNo1's avatar
TesterNo1
Contributor
9 years ago

how to replace entire parent node in request xml

 Hi all,   I have multiple tags in a request.i need to replace the root tag<Testing Root> so  i dont have to do it tag by tag.Does anyone have idea on how to do this ?     <Testing Root> <Sub T...
  • TesterNo1's avatar
    TesterNo1
    9 years ago

    thank you rao.

     

    I treid for long but figured out that i can dom object. Below code wored.

     


    def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
    def namespace = "http://pos.odc.vzwcorp.com";
    def holder = groovyUtils.getXmlHolder("Get Edge Installment Device#Request");
    def npanxxholder =groovyUtils.getXmlHolder("Npanxx Lookup Call#Request");
    holder.namespaces["ns1"] = namespace;
    npanxxholder.namespaces["ns1"] = namespace;

    use (groovy.xml.dom.DOMCategory){

    for( node in npanxxholder.getDomNodes( "//ns1:orderKeyInfo")) {
    node.children().each { child ->
    childname=child.name()
    childtext=child.text()
    log.info child.name()
    log.info child.text()
    //log.info "//ns1:"+"$childname"
    holder.setNodeValue("//ns1:"+"$childname",child.text())
    holder.updateProperty()
    }
    }

    }