title: Parsing XML on a Google Apps script
body: <p>Here's my XML: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
  &lt;response&gt;
      &lt;records&gt;
          &lt;record id='1'&gt;
              &lt;column name="Name"&gt;&lt;value&gt;&lt;![CDATA[John]]&gt;&lt;/value&gt;&lt;/column&gt;
              &lt;column name="Email"&gt;&lt;value&gt;&lt;![CDATA[john@gmail.com]]&gt;&lt;/value&gt;&lt;/column&gt;
          &lt;/record&gt;
          &lt;record id='2'&gt;
              &lt;column name="Name"&gt;&lt;value&gt;&lt;![CDATA[Joe]]&gt;&lt;/value&gt;&lt;/column&gt;
              &lt;column name="Email"&gt;&lt;value&gt;&lt;![CDATA[joe@gmail.com]]&gt;&lt;/value&gt;&lt;/column&gt;
          &lt;/record&gt;
      &lt;/records&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>And, here's my attempt to parse the above XML and return Name and email as arrays:</p>
  
  <pre><code>var document = XmlService.parse(the_above_xml);
  var root = document.getRootElement();
  var atom = XmlService.getNamespace('http://www.w3.org/2005/Atom');
  var records_all = document.getRootElement().getChildren('records', atom);
  for (r=0; r&lt;records_all.length; r++){
      var records = records_all[i].getChildren('record', atom);
      for (i=0; i&lt; records.length; i++){
          columns = records[i].getChildren('column', atom);
          for (c=0; c&lt; columns.length; c++){
              // I'm stuck here. I want to return an array of name and emails. 
          }
      }
  }
  </code></pre>
  
  <p>I was going through <a href="https://developers.google.com/apps-script/reference/xml-service/" rel="nofollow">https://developers.google.com/apps-script/reference/xml-service/</a> and couldn't figure out how to achieve it. How can I fix it?</p>