title: Gradle script : How to create and write data in XML file
body: <p>I am creating xml and via using gradle script and writing some data in xml file. I have created .gradle file and after running the gradle file i am not able to achieve the exact format for the xml file. i am posting my code below: Please anyone guide me .
  import groovy.xml.MarkupBuilder</p>
  
  <pre><code>task generatepublicxml {
  
      //def resDir = project.projectDir.absolutePath + "/src/main/res-public"
  
      // Create new public.xml with writer
      new File("/home/signity/Desktop/public.xml").withWriter { writer -&gt;
          // Create MarkupBuilder with 4 space indent
          def destXml = new MarkupBuilder(new IndentPrinter(writer, "    ", true));
          def destXmlMkp = destXml.getMkp();
  
          // GIST NOTE: our project needed the ResourceName suppression, but its not needed in general
          destXml.resources('xmlns:tools': 'http://schemas.android.com/tools', 'tools:ignore': 'ResourceName')
                  {
              // Leave file comment
              destXmlMkp.yield "\r\n"
              destXmlMkp.comment("AUTO-GENERATED FILE.  DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task")
  
          }
      }
  }
  </code></pre>
  
  <p>My Required File format:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;string name="remoteAccessConsumerKey"&gt;3MVG92mNMNiWvonjPDM9qqaDip0MFl9TGc&lt;/string&gt;
      &lt;string name="oauthRedirectURI"&gt;saleschap:///mobilesdk/detect/oauth/done&lt;/string&gt;
  
      &lt;string-array name="oauthScopes"&gt;
          &lt;item&gt;api&lt;/item&gt;
          &lt;item&gt;web&lt;/item&gt;
          &lt;item&gt;refresh_token&lt;/item&gt;
      &lt;/string-array&gt;
  
      &lt;string name="androidPushNotificationClientId"&gt;&lt;/string&gt;
  
  &lt;/resources&gt;
  </code></pre>