Skip to content Skip to sidebar Skip to footer

Parsing Xml Data Using Google Script

I have been trying to convert a xml feed into human readable form but have not succeeded . I have tried seeing the example given in tutorails section but its too complex. Please ca

Solution 1:

Looks root node opening tag is missing. Is it original doc? or just paste error?

Try like this

var response =UrlFetchApp.fetch("http://getRecords.php?  oauth_token=3e73c7&lat="+lat+"&lon="+lon+"&searchFor="+text+"&miles=100&response_type=xml");
var doc =Xml.parse(response.getContentText(), true);
var records = doc.records.getElements("record");
var entryList ="<ul>\n";

for (var i=0; i < records.length; i++) {
    var details = records[i].details;
    var name = details.name.getText();
    entryList +="<li>"+ name +"</li>\n";
}

entryList +="</ul>\n";
return entryList;

Post a Comment for "Parsing Xml Data Using Google Script"