title: Groovy script to Add node in SAP CPI
body: <p>I was trying to add node using  groovy script but output is showing like input.</p>
  <p>Input:</p>
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
    &lt;Records&gt;
       &lt;Line&gt;
       &lt;Field1&gt;ABC&lt;/Field1&gt;
       &lt;Field2&gt;123&lt;/Field2&gt;
       &lt;Field3&gt;XXX&lt;/Field3&gt;
       &lt;Field4&gt;567890&lt;/Field4&gt;
       &lt;/Line&gt;
     &lt;/Records&gt;
  </code></pre>
  <p>Code:</p>
  <pre><code>import com.sap.gateway.ip.core.customdev.util.Message;
  import java.util.HashMap;``
  import groovy.xml.XmlUtil;
  import groovy.util.*;
  
  def Message processData(Message message) {
  //Body 
     def body = message.getBody(java.lang.String) as String;
     def root = new XmlParser().parseText(body);
     root.Line[0].appendNode(&quot;Field5&quot;, [:], &quot;MyNewField&quot;);
     return message;
  }  
  </code></pre>
  <p>please help in creating new node using groovy script</p>
  <p>getting this error when xml path also 'enter code here`
  No signature of method: groovy.util.NodeList.appendNode()</p>
  <p>Hi</p>
  <p>Really thank you so much for your response. My actual requirement contains multiple repeating nodes structure as below groovy IDE <a href="https://groovyide.com/cpi/share/v1/zVRtT9swEP4rnj-1U3H6AhsrIWiUoX4Y01gpqkT44CXX1pNjZ7ZT6FD_-86JK0rh-2Ypyvl57nzne_ETFaqsHB0-0Z86X9Mhjc8eC0lWYKzQ6jSlPdZNKQGV6VyoBQLTm8uD45SeJamKb3_L6wrM-gdYh18lHaKpiw3YUisLE8ddZZPJdDT6MpnE0R7-QvcCHBeyARGWohAu6XW73Thq5EDo-dyCSxAOUsCt-APJII7qf8Ccdlx6sBFqf9FbDuOcO761MvohiLi5FCDzXvL5fBRHQX7J9ZNefxC4_h43SGazWeAGe9xhcvTh4_GnbqAPt96jZ_c7kRBc_0ss_zQrcRRKFUdvdh_t0CXwHPvXN7WW-bjeYWePQUr9jm46tDS6BOMEeJ0NAjYzoqynANscUFcUpTaOZLpglpdswR088DUTJcu0AZZV1ukihxWrnJDsCqzlCzhJVbD7xVe8ocbcLq94-UwtjNarNcMhY7NCTlHnFVcbvkc4VTnMSTidYNQZihd4_dYWK5p_mzw1un6IyekWZgtw54i06ngkVws2cQbHuH3SqKM_h-oKHggG850bC6bVZqUXbuDRtfx57VR5PfY63Qx4tvSuSVi3118b5iB5A2S-cq9s_PLEN8z8rtkuzrD6d917xssSVO6RVkrrBjlKaYfcDe87JKV4jbnHUurv13TV5vlAFLd5sSEvoQK4N4JLfDha_qZtb27AVUZtM4nAhpC6u-aVyhy-jdglOxWhm81f" rel="nofollow noreferrer">link.</a> Please take look of below code example. I was getting similar issue as below.</p>