Google docs ImportXML called from script

末鹿安然 提交于 2019-12-06 11:56:05

I have solved this now in a different way. It is more common to use UrlFetchapp() within google doc scripts than ImportXML. But you have to gain the xml data yourself from the http response.

I do it in this way now:

var response = UrlFetchApp.fetch(apiString).getContentText();
var xmlContent = Xml.parse(response, true);
var answer = xmlContent.response.answer; 

// get what you need from the XML answer
if (answer != null)
{
    var element = answer.getElement('foo');
    if (element != null)
    {
        var attrib = element.getAttribute('bar');    
        if (attrib != null)
            value = attrib.getValue();  // the value you want
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!