Forum Discussion

TesterNo1's avatar
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 Test 1>

<Sub Test 2>
<Sub Test 3>

</Testing Root>


thanks you 


  • thank you rao.


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


    def groovyUtils = new;
    def namespace = "";
    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 ->
    childtext=child.text() child.text()
    // "//ns1:"+"$childname"


4 Replies

  • nmrao's avatar
    Champion Level 3
    It would be helpful if you provide the context, and the use case that you are trying to achieve.
    • TesterNo1's avatar
      Rao,I need to transfer node and child nodes from one api to other using groovy.all child nodes inside the main node are common meaning they are both same tags.only values needs to be replaced/ transferred
      • nmrao's avatar
        Champion Level 3
        Well. If you want to provide sample source and target and datamapping between the two, would be great.