2014-09-23 66 views

回答

0

您可以在创建元素时将名称空间添加到元素。见XmlService.createElement(String, Namespace)。但是,如果您尝试为第二个参数传递字符串文字,则Google Apps脚本会引发错误。你需要做的是调用XmlService.getNamespace(prefix, uri)方法来创建一个Namespace对象。然后可以将该名称空间对象作为第二个参数传递。

// Create a namespace object. 
ns = XmlService.getNamespace("xsi", 
    "http://www.w3.org/2001/XMLSchema-instance"); 

// Create an element. 
var el = XmlService.createElement('devdef'); 

// Set the namespace of the element. 
el.setNamespace(ns); 
相关问题