title: How do I parse all values from a given XML element using a Google App Script?
body: <p>I am trying to parse temperature data into a google spreadsheet from a NOAA source with xml of the form:</p>
  
  <p>.....
  <code>&lt;parameters applicable-location="point1"&gt;</code><br>
  <code>&lt;temperature type="maximum" units="Fahrenheit" time-layout="k-p24h-n7-1"&gt;</code><br>
  <code>&lt;name&gt;Daily Maximum Temperature&lt;/name&gt;</code><br>
  <code>&lt;value&gt;63&lt;/value&gt;</code><br>
  <code>&lt;value&gt;72&lt;/value&gt;</code><br>
  <code>&lt;value&gt;76&lt;/value&gt;</code><br>
  <code>&lt;value&gt;78&lt;/value&gt;</code><br>
  <code>&lt;value&gt;74&lt;/value&gt;</code><br>
  <code>&lt;value&gt;62&lt;/value&gt;</code><br>
  <code>&lt;value&gt;58&lt;/value&gt;</code><br>
  <code>&lt;/temperature&gt;</code><br>
  <code>&lt;temperature type="minimum" units="Fahrenheit" time-layout="k-p24h-n6-2"&gt;</code><br>
  <code>&lt;name&gt;Daily Minimum Temperature&lt;/name&gt;</code><br>
  <code>&lt;value&gt;52&lt;/value&gt;</code><br>
  <code>&lt;value&gt;58&lt;/value&gt;</code><br>
  <code>&lt;value&gt;56&lt;/value&gt;</code><br>
  <code>&lt;value&gt;60&lt;/value&gt;</code><br>
  <code>&lt;value&gt;48&lt;/value&gt;</code><br>
  <code>&lt;value&gt;45&lt;/value&gt;</code><br>
  <code>&lt;/temperature&gt;</code><br>
  <code>&lt;/parameters&gt;</code><br>
  <code>&lt;/data&gt;</code><br>
  <code>&lt;/dwml&gt;</code><br></p>
  
  <p>I would like each of the numbers inside the  tags from both the maximum and minimum headings to be in separate cell in a spreadsheet. My current script is:</p>
  
  <p><code>function Temperatures() {
  var text = UrlFetchApp.fetch("http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?whichClient=NDFDgen&amp;lat=38.99&amp;lon=-77.01&amp;listLatLon=&amp;lat1=&amp;lon1=&amp;lat2=&amp;lon2=&amp;resolutionSub=&amp;listLat1=&amp;listLon1=&amp;listLat2=&amp;listLon2=&amp;resolutionList=&amp;endPoint1Lat=&amp;endPoint1Lon=&amp;endPoint2Lat=&amp;endPoint2Lon=&amp;listEndPoint1Lat=&amp;listEndPoint1Lon=&amp;listEndPoint2Lat=&amp;listEndPoint2Lon=&amp;zipCodeList=&amp;listZipCodeList=&amp;centerPointLat=&amp;centerPointLon=&amp;distanceLat=&amp;distanceLon=&amp;resolutionSquare=&amp;listCenterPointLat=&amp;listCenterPointLon=&amp;listDistanceLat=&amp;listDistanceLon=&amp;listResolutionSquare=&amp;citiesLevel=&amp;listCitiesLevel=&amp;sector=&amp;gmlListLatLon=&amp;featureType=&amp;requestedTime=&amp;startTime=&amp;endTime=&amp;compType=&amp;propertyName=&amp;product=time-series&amp;begin=2004-01-01T00%3A00%3A00&amp;end=2017-04-12T00%3A00%3A00&amp;Unit=e&amp;maxt=maxt&amp;mint=mint&amp;Submit=Submit").getContentText();</code><br>
    <code>return parse(text);</code><br>
  <code>function parse(text) {</code><br>
    <code>var doc = Xml.parse(text, true);</code><br>
    <code>var temps = doc.dwml.data.getElement("parameters").getElement("temperature").getElements("value").getText();</code><br>
    <code>return temps</code><br>
  <code>}</code><br>
  <code>}</code><br></p>
  
  <p>However, running this script parses only a single reading—the first  tag, 63, into a cell. If I change .getElement(“value”).getText(); to .getElements(“value”).getText(); I receive the following error message: “TypeError: Cannot find function getText in object.”</p>
  
  <p>Thank you for any advice you can provide.</p>
  
  <p>Ron</p>