Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I'm trying to get the value of all the fields in the loop, then insert data into googlesheet.
XML:
XML
<issues total_count="210" offset="0" limit="25" type="array">
    <issue>
    <id>22079</id>
    <project id="21" name="name1"/>
    <description>Some text</description>
    <start_date>2017-11-22</start_date>
    <custom_fields type="array">
    <custom_field id="36" name="cf_36">
    <value>cf_36_value</value>
    </custom_field>
    <custom_field id="28" name="cf_28">
    <value>cf_28_value</value>
    </custom_field>
    <value type="array"/>
    </custom_field>
    </custom_fields>
    </issue>


What I have tried:

JavaScript
function APIRequest (url,sheet) {

  var xml = UrlFetchApp.fetch(url).getContentText();

  var DOC = Xml.parse(xml);
  var issues = DOC.issues.issue

  for(var c=0; c<issues.length;c++){
   var issue = issues[c];
    var id = issue.getElement('id').getText();

  sheet.appendRow([id]);
  }
 }

My problem is that I cann't get the values "cf_36_value" from XML for each "issue"
Help me plz
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900